openapi: 3.1.0
info:
  title: Variscreen Solutions API
  version: 1.0.0
  description: |-
    REST API for Variscreen Solutions platform.
    All authenticated endpoints require a Bearer token in the Authorization header.
    Tokens are obtained via `/api/auth/login` or `/api/auth/signup`.

    **Response envelope:**
    - Success with data: `{ "data": T }`
    - Success without data: `{ "success": true }`
    - Error: `{ "error": "message", "details": "optional" }`

    **Rate limiting:** Auth endpoints are limited to 10 requests per 15 minutes per IP.
  contact:
    name: Variscreen Solutions
servers:
  - url: https://variscreen-solutions.fly.dev
    description: Production
  - url: http://localhost:3000
    description: Local development
tags:
  - name: Auth
    description: Authentication — login, signup, token refresh, OAuth, OTP, password reset
  - name: Portal
    description: Customer portal — profile, biomarkers, health summary, result downloads
  - name: Orders
    description: Order management — list, create, update, delete orders
  - name: OrderItems
    description: Order line items — update, bulk operations
  - name: Results
    description: Lab results and test panels
  - name: Public
    description: Public endpoints — no authentication required
  - name: Payments
    description: Stripe checkout and payment verification
  - name: Feedback
    description: User feedback submission
  - name: Consent
    description: User consent / e-signature management
  - name: People
    description: Person records and profile status
  - name: Organizations
    description: Organization management — CRUD, bulk operations
  - name: Products
    description: Product catalog management
  - name: DeviceActivations
    description: Device activation flows — confirmation, steps, return labels
  - name: TestPanels
    description: Lab test panel configuration
  - name: Platform
    description: Platform administration — users, roles, settings, devices, branding
  - name: Educational
    description: Educational content — articles, videos, categories
  - name: Connectors
    description: External service connectors
  - name: BiomarkerHistory
    description: Biomarker result history and trends
  - name: Branding
    description: Organization branding configuration
  - name: EmailTemplates
    description: Email template management and send logs
  - name: Integrations
    description: Third-party integrations
  - name: Internal
    description: Internal/debug endpoints — metrics, logs, cron, design system
security: []
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Supabase-issued JWT access token obtained from /api/auth/login or /api/auth/signup
    ServiceRoleKey:
      type: apiKey
      in: header
      name: Authorization
      description: Supabase service-role key passed as Bearer token. Used for server-to-server calls that bypass RLS.
    CronSecret:
      type: apiKey
      in: header
      name: Authorization
      description: CRON_SECRET environment variable passed as Bearer token for scheduled job endpoints.
    WebhookSignature:
      type: apiKey
      in: header
      name: stripe-signature
      description: Stripe webhook signature header verified via STRIPE_WEBHOOK_SECRET.
  schemas:
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          example: Authentication required
        details:
          type: string
    SuccessResponse:
      type: object
      required:
        - success
      properties:
        success:
          type: boolean
          enum:
            - true
    UserSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        email:
          type: string
          format: email
        user_metadata:
          type: object
          properties:
            first_name:
              type: string
            last_name:
              type: string
            full_name:
              type: string
    AuthTokens:
      type: object
      required:
        - access_token
        - refresh_token
        - expires_at
        - user
      properties:
        access_token:
          type: string
        refresh_token:
          type: string
        expires_at:
          type: integer
          description: Unix timestamp when the access token expires
        user:
          $ref: "#/components/schemas/UserSummary"
    LoginRequest:
      type: object
      required:
        - email
        - password
      properties:
        email:
          type: string
          format: email
        password:
          type: string
          minLength: 1
    SignupRequest:
      type: object
      required:
        - email
        - password
        - firstName
        - lastName
        - acceptedTerms
      properties:
        email:
          type: string
          format: email
        password:
          type: string
          minLength: 8
        firstName:
          type: string
          minLength: 1
        middleInitial:
          type: string
          maxLength: 1
          description: Optional middle initial (single character)
        lastName:
          type: string
          minLength: 1
        redirectTo:
          type: string
        acceptedTerms:
          type: boolean
          description: Must be true to accept Terms of Service and Privacy Policy
    SignupResponseImmediate:
      type: object
      required:
        - confirmEmail
        - access_token
        - refresh_token
        - expires_at
        - user
      properties:
        confirmEmail:
          type: boolean
          enum:
            - false
        access_token:
          type: string
        refresh_token:
          type: string
        expires_at:
          type: integer
        user:
          $ref: "#/components/schemas/UserSummary"
        requiresConsent:
          type: boolean
          description: Deprecated (HO-591); portal clinical consent gate removed.
        requiresLoginTerms:
          type: boolean
          description: If true, user must complete login-step Terms/Privacy (e.g. POST /api/consent/login-terms).
    SignupResponseConfirm:
      type: object
      required:
        - confirmEmail
        - user
      properties:
        confirmEmail:
          type: boolean
          enum:
            - true
        user:
          type: object
          properties:
            id:
              type: string
              format: uuid
            email:
              type: string
              format: email
    RefreshRequest:
      type: object
      required:
        - refresh_token
      properties:
        refresh_token:
          type: string
          minLength: 1
    OtpRequest:
      type: object
      required:
        - email
      properties:
        email:
          type: string
          format: email
        shouldCreateUser:
          type: boolean
        emailRedirectTo:
          type: string
          format: uri
    ResetPasswordRequest:
      type: object
      required:
        - email
      properties:
        email:
          type: string
          format: email
        redirectTo:
          type: string
          format: uri
          description: Optional. Only honored when the URL path is /reset-password or legacy /auth/reset-password on an allowed
            origin; otherwise the email link uses the site default /reset-password.
    UpdatePasswordRequest:
      type: object
      required:
        - password
      properties:
        token:
          type: string
          description: Recovery token from password reset email link (required when no Bearer token is provided)
        password:
          type: string
          format: password
          minLength: 8
          description: New password (minimum 8 characters)
    PortalProfile:
      type: object
      properties:
        userEmail:
          type:
            - string
            - "null"
          format: email
        personId:
          type:
            - string
            - "null"
          format: uuid
        organizationId:
          type:
            - string
            - "null"
          format: uuid
        profileUpdateRequired:
          type: boolean
    Biomarker:
      type: object
      properties:
        id:
          type: string
        name:
          type: string
        code:
          type: string
        value:
          type: number
        unit:
          type: string
        range_low:
          type: number
        range_high:
          type: number
        is_optimal:
          type: boolean
        category:
          type: string
          enum:
            - Metabolic
            - Hematology
            - Thyroid
            - Lipids
            - Other
    DashboardStats:
      type: object
      properties:
        totalOrders:
          type: integer
        totalRevenue:
          type: number
        pendingResults:
          type: integer
        totalUsers:
          type: integer
        recentOrders:
          type: array
          items:
            $ref: "#/components/schemas/Order"
        revenueByMonth:
          type: object
          additionalProperties:
            type: number
    HealthSummary:
      type: object
      properties:
        total_biomarkers:
          type: integer
        optimal_count:
          type: integer
        attention_count:
          type: integer
        health_score:
          type: integer
          description: Percentage 0-100
        last_test_date:
          type:
            - string
            - "null"
          format: date-time
        categories:
          type: array
          items:
            type: object
            properties:
              name:
                type: string
              total:
                type: integer
              optimal:
                type: integer
    PortalBiomarkerHistoryPoint:
      type: object
      required:
        - date
        - value
      properties:
        date:
          type: string
          format: date
        value:
          type: number
        order:
          type: string
    PortalBiomarkerWithHistory:
      type: object
      required:
        - id
        - name
        - slug
        - code
        - unit
        - value
        - result_state
        - history
      properties:
        id:
          type: string
        name:
          type: string
        slug:
          type: string
        code:
          type: string
        unit:
          type: string
        value:
          type:
            - number
            - "null"
        range_low:
          type:
            - number
            - "null"
        range_high:
          type:
            - number
            - "null"
        reference_label:
          type: string
        range_display:
          type: string
        is_optimal:
          type:
            - boolean
            - "null"
        result_state:
          type: string
          enum:
            - optimal
            - abnormal
            - unknown
        category:
          type: string
        description:
          type: string
        tips:
          type: array
          items:
            type: string
        note:
          type: string
        history:
          type: array
          items:
            $ref: "#/components/schemas/PortalBiomarkerHistoryPoint"
    PortalBiomarkersEnvelope:
      type: object
      required:
        - biomarkers
      properties:
        biomarkers:
          type: array
          items:
            $ref: "#/components/schemas/PortalBiomarkerWithHistory"
    BiomarkerHistoryGroupedEnvelope:
      type: object
      required:
        - biomarkers
      properties:
        biomarkers:
          type: array
          items:
            $ref: "#/components/schemas/PortalBiomarkerWithHistory"
    PortalBootstrapResponse:
      type: object
      required:
        - portal_me
        - profile_status
        - device_activations
        - biomarkers
        - health_summary
      properties:
        portal_me:
          $ref: "#/components/schemas/PortalProfile"
        profile_status:
          $ref: "#/components/schemas/ProfileStatus"
        device_activations:
          type: array
          items:
            $ref: "#/components/schemas/DeviceActivation"
        biomarkers:
          $ref: "#/components/schemas/PortalBiomarkersEnvelope"
        health_summary:
          $ref: "#/components/schemas/HealthSummary"
    DownloadUrl:
      type: object
      required:
        - url
        - expires_in
      properties:
        url:
          type: string
          format: uri
        expires_in:
          type: integer
          description: Seconds until URL expires
          example: 3600
    PartnershipCategory:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        icon:
          type:
            - string
            - "null"
        sort_order:
          type: integer
        is_active:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    PartnershipCategoryWithCount:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        icon:
          type:
            - string
            - "null"
        count:
          type: integer
    Partnership:
      type: object
      properties:
        id:
          type: string
          format: uuid
        category_id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        perk_summary:
          type:
            - string
            - "null"
        redemption_url:
          type:
            - string
            - "null"
          format: uri
        redemption_code:
          type:
            - string
            - "null"
        logo_url:
          type:
            - string
            - "null"
          format: uri
        is_active:
          type: boolean
        sort_order:
          type: integer
        redemption_limit:
          type:
            - integer
            - "null"
        metadata:
          type: object
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        category:
          $ref: "#/components/schemas/PartnershipCategory"
    PartnershipPortal:
      type: object
      properties:
        id:
          type: string
          format: uuid
        category_id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        perk_summary:
          type:
            - string
            - "null"
        redemption_url:
          type:
            - string
            - "null"
          format: uri
        redemption_code:
          type:
            - string
            - "null"
        logo_url:
          type:
            - string
            - "null"
          format: uri
        sort_order:
          type: integer
        redeemed:
          type: boolean
        redeemed_at:
          type:
            - string
            - "null"
          format: date-time
    PartnershipRedemption:
      type: object
      properties:
        id:
          type: string
          format: uuid
        person_id:
          type: string
          format: uuid
        redeemed_at:
          type: string
          format: date-time
        redemption_code:
          type:
            - string
            - "null"
        redemption_url:
          type:
            - string
            - "null"
          format: uri
    PartnershipRedeemResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        redeemed_at:
          type: string
          format: date-time
        redemption_code:
          type:
            - string
            - "null"
        redemption_url:
          type:
            - string
            - "null"
          format: uri
    PartnershipRedemptionsResponse:
      type: object
      properties:
        count:
          type: integer
        redemptions:
          type: array
          items:
            $ref: "#/components/schemas/PartnershipRedemption"
    PartnershipCategoryCreateRequest:
      type: object
      required:
        - name
      properties:
        name:
          type: string
          minLength: 1
        description:
          type:
            - string
            - "null"
        icon:
          type:
            - string
            - "null"
        sort_order:
          type: integer
        is_active:
          type: boolean
    PartnershipCategoryUpdateRequest:
      type: object
      required:
        - id
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
          minLength: 1
        description:
          type:
            - string
            - "null"
        icon:
          type:
            - string
            - "null"
        sort_order:
          type: integer
        is_active:
          type: boolean
    PartnershipCreateRequest:
      type: object
      required:
        - name
      properties:
        category_id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
          minLength: 1
        description:
          type:
            - string
            - "null"
        perk_summary:
          type:
            - string
            - "null"
        redemption_url:
          type:
            - string
            - "null"
          format: uri
        redemption_code:
          type:
            - string
            - "null"
        logo_url:
          type:
            - string
            - "null"
          format: uri
        is_active:
          type: boolean
        sort_order:
          type: integer
        redemption_limit:
          type:
            - integer
            - "null"
        metadata:
          type: object
    PartnershipUpdateRequest:
      type: object
      required:
        - id
      properties:
        id:
          type: string
          format: uuid
        category_id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
          minLength: 1
        description:
          type:
            - string
            - "null"
        perk_summary:
          type:
            - string
            - "null"
        redemption_url:
          type:
            - string
            - "null"
          format: uri
        redemption_code:
          type:
            - string
            - "null"
        logo_url:
          type:
            - string
            - "null"
          format: uri
        is_active:
          type: boolean
        sort_order:
          type: integer
        redemption_limit:
          type:
            - integer
            - "null"
        metadata:
          type: object
    Order:
      type: object
      properties:
        id:
          type: string
          format: uuid
        order_number:
          type: string
        person_id:
          type:
            - string
            - "null"
          format: uuid
        organization_id:
          type:
            - string
            - "null"
          format: uuid
        product_type:
          type: string
        status:
          type: string
          enum:
            - pending
            - confirmed
            - activated
            - collecting
            - in_transit
            - delivered_to_lab
            - processing_at_lab
            - completed
            - cancelled
        payment_status:
          type: string
          enum:
            - pending
            - paid
            - refunded
            - failed
        amount_cents:
          type: integer
        currency:
          type: string
          example: USD
        device_id:
          type:
            - string
            - "null"
          format: uuid
        metadata:
          type: object
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    OrderWithRelations:
      allOf:
        - $ref: "#/components/schemas/Order"
        - type: object
          properties:
            people_with_auth:
              type:
                - object
                - "null"
              properties:
                id:
                  type: string
                  format: uuid
                user_id:
                  type: string
                  format: uuid
                role:
                  type: string
                name:
                  type: string
                email:
                  type: string
                  format: email
            order_items:
              type: array
              items:
                $ref: "#/components/schemas/OrderItem"
            device_activations:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  activation_uid:
                    type: string
    OrderItem:
      type: object
      properties:
        id:
          type: string
          format: uuid
        quantity:
          type: integer
        price_cents:
          type: integer
        status:
          type: string
        activation_uid:
          type:
            - string
            - "null"
        tracking_number:
          type:
            - string
            - "null"
        carrier:
          type:
            - string
            - "null"
        tracking_url:
          type:
            - string
            - "null"
        shipped_at:
          type:
            - string
            - "null"
          format: date-time
        delivered_at:
          type:
            - string
            - "null"
          format: date-time
        activated_at:
          type:
            - string
            - "null"
          format: date-time
        return_tracking_number:
          type:
            - string
            - "null"
        return_tracking_carrier:
          type:
            - string
            - "null"
        return_tracking_url:
          type:
            - string
            - "null"
        return_label_url:
          type:
            - string
            - "null"
        return_label_issued_at:
          type:
            - string
            - "null"
          format: date-time
        return_shipped_at:
          type:
            - string
            - "null"
          format: date-time
        return_received_at:
          type:
            - string
            - "null"
          format: date-time
        product:
          type:
            - object
            - "null"
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            image_url:
              type:
                - string
                - "null"
            panel:
              type:
                - object
                - "null"
              properties:
                id:
                  type: string
                  format: uuid
                name:
                  type: string
                description:
                  type:
                    - string
                    - "null"
                component_test_names:
                  type: array
                  items:
                    type: string
        device:
          type:
            - object
            - "null"
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
    CreateOrderRequest:
      type: object
      required:
        - person_id
        - product_type
        - amount_cents
        - currency
      properties:
        person_id:
          type: string
          format: uuid
        product_type:
          type: string
        amount_cents:
          type: integer
        currency:
          type: string
          example: USD
        device_id:
          type: string
          format: uuid
        metadata:
          type: object
    UpdatePlatformOrderRequest:
      type: object
      properties:
        status:
          type: string
        payment_status:
          type: string
        amount_cents:
          type: integer
        currency:
          type: string
        product_type:
          type: string
          enum:
            - at_home_kit
            - labcorp_psc
        tracking_number:
          type:
            - string
            - "null"
        customer_email:
          type:
            - string
            - "null"
          format: email
        order_number:
          type: string
        person_id:
          type: string
          format: uuid
    OrderPanel:
      type: object
      properties:
        id:
          type: string
        order_number:
          type: string
          description: Denormalized from `order.order_number` when absent on the row; convenience for portal list UIs.
        order_id:
          type: string
          format: uuid
        order_item_id:
          type: string
          format: uuid
        panel_id:
          type:
            - string
            - "null"
          format: uuid
        panel_name:
          type: string
        panel_description:
          type:
            - string
            - "null"
        panel_status:
          type: string
          enum:
            - pending
            - sample_collected
            - received_at_lab
            - processing
            - completed
            - reviewed
            - cancelled
        status:
          type: string
          enum:
            - pending
            - sample_collected
            - received_at_lab
            - processing
            - completed
            - reviewed
            - cancelled
          description: Legacy duplicate of `panel_status` for older clients. Prefer `panel_status` for new code.
        sample_collected_at:
          type:
            - string
            - "null"
          format: date-time
        received_at_lab_at:
          type:
            - string
            - "null"
          format: date-time
        processing_started_at:
          type:
            - string
            - "null"
          format: date-time
        completed_at:
          type:
            - string
            - "null"
          format: date-time
        reviewed_at:
          type:
            - string
            - "null"
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        order:
          type: object
          properties:
            id:
              type: string
              format: uuid
            order_number:
              type: string
            status:
              type: string
            person_id:
              type: string
              format: uuid
            created_at:
              type: string
              format: date-time
            order_results:
              type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                    format: uuid
                  source_pdf_url:
                    type:
                      - string
                      - "null"
                  result_url:
                    type:
                      - string
                      - "null"
        order_item:
          type:
            - object
            - "null"
          properties:
            id:
              type: string
              format: uuid
            product:
              type:
                - object
                - "null"
              properties:
                id:
                  type: string
                  format: uuid
                name:
                  type: string
                image_url:
                  type:
                    - string
                    - "null"
            device:
              type:
                - object
                - "null"
              properties:
                id:
                  type: string
                  format: uuid
                name:
                  type: string
        panel_test_results:
          type: array
          items:
            $ref: "#/components/schemas/PanelTestResult"
    PanelTestResult:
      type: object
      properties:
        id:
          type: string
        test_name:
          type: string
        test_code:
          type:
            - string
            - "null"
        status:
          type: string
        result_value:
          type:
            - string
            - "null"
        result_numeric:
          type:
            - number
            - "null"
        result_unit:
          type:
            - string
            - "null"
        reference_range:
          type:
            - string
            - "null"
        is_abnormal:
          type: boolean
        qualitative_result:
          type:
            - string
            - "null"
        sample_collected_at:
          type:
            - string
            - "null"
          format: date-time
        received_at_lab_at:
          type:
            - string
            - "null"
          format: date-time
        processing_started_at:
          type:
            - string
            - "null"
          format: date-time
        completed_at:
          type:
            - string
            - "null"
          format: date-time
        reviewed_at:
          type:
            - string
            - "null"
          format: date-time
        notes:
          type:
            - string
            - "null"
        panel_test:
          type:
            - object
            - "null"
          properties:
            id:
              type: string
              format: uuid
            display_name:
              type: string
            description:
              type:
                - string
                - "null"
            default_units:
              type:
                - string
                - "null"
            reference_range:
              type:
                - string
                - "null"
    HealthCheck:
      type: object
      required:
        - status
        - timestamp
        - service
      properties:
        status:
          type: string
          example: ok
        timestamp:
          type: string
          format: date-time
        service:
          type: string
          example: variscreen-platform-api
    EmailHealthStatus:
      type: object
      required:
        - status
        - config
        - timestamp
      properties:
        status:
          type: string
          enum:
            - healthy
            - degraded
            - error
        config:
          type: object
          required:
            - provider
            - mode
            - isProduction
            - warnings
          properties:
            provider:
              type: string
            mode:
              type: string
            isProduction:
              type: boolean
            warnings:
              type: array
              items:
                type: string
        timestamp:
          type: string
          format: date-time
    PlatformStatus:
      type: object
      properties:
        maintenanceMode:
          type: boolean
        visualOverlayEnabled:
          type: boolean
        companyName:
          type: string
    OrgBranding:
      type: object
      properties:
        id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
        logo_url:
          type:
            - string
            - "null"
        primary_color:
          type: string
          example: "#C87254"
        accent_color:
          type: string
          example: "#8B4513"
        hero_title:
          type:
            - string
            - "null"
        template:
          type:
            - string
            - "null"
    ChangelogRelease:
      type: object
      required:
        - version
        - tag
        - title
        - date
        - body
        - isLatest
        - isPrerelease
      properties:
        version:
          type: string
          description: Release version (date-based from DB or semver from GitHub)
        tag:
          type: string
        title:
          type: string
        date:
          type: string
          format: date-time
        body:
          type: string
          description: Markdown release notes
        isLatest:
          type: boolean
        isPrerelease:
          type: boolean
    ChangelogPagination:
      type: object
      required:
        - page
        - per_page
        - total
        - total_pages
        - has_more
      properties:
        page:
          type: integer
          minimum: 1
        per_page:
          type: integer
          minimum: 1
        total:
          type: integer
          minimum: 0
        total_pages:
          type: integer
          minimum: 0
        has_more:
          type: boolean
    ChangelogResponse:
      type: object
      required:
        - releases
        - source
      properties:
        releases:
          type: array
          items:
            $ref: "#/components/schemas/ChangelogRelease"
        source:
          type: string
          enum:
            - db
            - github
            - cache
            - fallback
          description: Where releases were loaded from
        pagination:
          $ref: "#/components/schemas/ChangelogPagination"
    Role:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        display_name:
          type: string
        description:
          type:
            - string
            - "null"
    PublicOrderRequest:
      type: object
      required:
        - email
        - firstName
        - lastName
        - address
        - city
        - state
        - zip
        - items
        - subtotal_cents
        - total_cents
      properties:
        email:
          type: string
          format: email
        firstName:
          type: string
          minLength: 1
        lastName:
          type: string
          minLength: 1
        address:
          type: string
          minLength: 1
        city:
          type: string
          minLength: 1
        state:
          type: string
          minLength: 2
        zip:
          type: string
          minLength: 5
        country:
          type: string
          default: US
        items:
          type: array
          minItems: 1
          items:
            type: object
            required:
              - product_id
              - product_name
              - quantity
              - price_cents
            properties:
              product_id:
                type: string
                format: uuid
              product_name:
                type: string
              quantity:
                type: integer
                minimum: 1
              price_cents:
                type: integer
                minimum: 0
        subtotal_cents:
          type: integer
          minimum: 0
        tax_cents:
          type: integer
          default: 0
        shipping_cents:
          type: integer
          default: 0
        total_cents:
          type: integer
          minimum: 0
    PublicOrderResponse:
      type: object
      properties:
        success:
          type: boolean
        order:
          type: object
          properties:
            id:
              type: string
              format: uuid
            order_number:
              type: string
            status:
              type: string
            amount_cents:
              type: integer
    CheckoutSessionRequest:
      type: object
      required:
        - successUrl
        - cancelUrl
      properties:
        successUrl:
          type: string
          format: uri
        cancelUrl:
          type: string
          format: uri
    CheckoutSessionResponse:
      type: object
      properties:
        sessionId:
          type: string
        url:
          type: string
          format: uri
    ConsentStatus:
      type: object
      properties:
        requiresConsent:
          type: boolean
          description: Deprecated (HO-591); always false for portal gate. Clinical consent via kit / POST /api/consent/accept.
        requiresLoginTerms:
          type: boolean
          description: Non–platform_employee users must complete login-step terms.
        hasAcceptedLoginTerms:
          type: boolean
        loginTermsAcceptedAt:
          type:
            - string
            - "null"
          format: date-time
        loginTermsVersion:
          type:
            - string
            - "null"
        hasAcceptedConsent:
          type: boolean
          description: Clinical/portal consent flag (kit activation flow).
        personId:
          type:
            - string
            - "null"
          format: uuid
        consentAcceptedAt:
          type:
            - string
            - "null"
          format: date-time
        consentVersion:
          type:
            - string
            - "null"
        consentText:
          type:
            - string
            - "null"
        items:
          type: array
          items:
            type: object
            additionalProperties: true
    LoginTermsAcceptRequest:
      type: object
      properties:
        bundle_version:
          type: string
          description: Optional version string stored on people and member_consents rows.
    LoginTermsAcceptResponse:
      type: object
      properties:
        alreadyAccepted:
          type: boolean
        personId:
          type: string
          format: uuid
        signedAt:
          type: string
          format: date-time
    ConsentAcceptRequest:
      type: object
      required:
        - person_id
      properties:
        person_id:
          type: string
          format: uuid
        consent_version:
          type: string
        envelope_id:
          type: string
          description: DocuSign envelope ID (required when DocuSign consent flow is active)
        accepted_items:
          type: array
          items:
            type: string
          description: Array of accepted consent item IDs (required if config has required items)
    ConsentAcceptResponse:
      type: object
      properties:
        success:
          type: boolean
        message:
          type: string
        consentVersion:
          type: string
        signedAt:
          type: string
          format: date-time
        signatureMethod:
          type: string
          enum:
            - manual
            - docusign
        envelope:
          type:
            - object
            - "null"
    MemberConsent:
      type: object
      properties:
        id:
          type: string
          format: uuid
        person_id:
          type: string
          format: uuid
        consent_type:
          type: string
        version:
          type: string
        signed_at:
          type:
            - string
            - "null"
          format: date-time
        ip_address:
          type:
            - string
            - "null"
        user_agent:
          type:
            - string
            - "null"
        signature_method:
          type:
            - string
            - "null"
        context:
          type: object
        metadata:
          type: object
        order_id:
          type:
            - string
            - "null"
          format: uuid
        created_at:
          type: string
          format: date-time
    ConsentDeclineRequest:
      type: object
      required:
        - person_id
        - reason
      properties:
        person_id:
          type: string
          format: uuid
        reason:
          type: string
          enum:
            - decline
            - not_now
        bundle_version:
          type: string
          description: Optional audit version shown on portal profile
    ConsentDeclineResponse:
      type: object
      properties:
        success:
          type: boolean
        reason:
          type: string
          enum:
            - decline
            - not_now
        personId:
          type: string
          format: uuid
        signedAt:
          type: string
          format: date-time
        version:
          type: string
          description: Stored member_consents.version (bundle_version or "0")
        deduplicated:
          type: boolean
          description: True when an identical decline was already recorded within the dedupe window
    ProfileStatus:
      type: object
      properties:
        profile_update_required:
          type: boolean
    PersonMe:
      type: object
      properties:
        person:
          type:
            - object
            - "null"
          description: Full person record or null if not found
        has_membership:
          type: boolean
          description: Only present when organization_id query param is provided
    VerifyDriverLicenseMockRequest:
      type: object
      properties:
        driver_license:
          type: string
          maxLength: 100
          description: Optional; must match profile when provided
    VerifyDriverLicenseMockResponse:
      type: object
      required:
        - verified
        - mock
        - driver_license_verified_at
        - message
      properties:
        verified:
          type: boolean
        mock:
          type: boolean
          description: Always true for this endpoint
        driver_license_verified_at:
          type: string
          format: date-time
        message:
          type: string
    AddressValidationRequest:
      type: object
      required:
        - address
      properties:
        address:
          type: string
          minLength: 1
          maxLength: 500
        previousResponseId:
          type: string
          maxLength: 256
        regionCode:
          type: string
          minLength: 2
          maxLength: 2
          description: ISO 3166-1 alpha-2 hint
    AddressValidationFields:
      type: object
      properties:
        address_line1:
          type:
            - string
            - "null"
        address_line2:
          type:
            - string
            - "null"
        city:
          type:
            - string
            - "null"
        state:
          type:
            - string
            - "null"
        zip_code:
          type:
            - string
            - "null"
        country:
          type:
            - string
            - "null"
          description: ISO 3166-1 alpha-2
    AddressValidationResult:
      type: object
      required:
        - fields
        - verdict
        - responseId
      properties:
        fields:
          $ref: "#/components/schemas/AddressValidationFields"
        verdict:
          type: string
          description: CONFIRMED | UNCONFIRMED | PARTIAL | UNKNOWN
        verdictDetail:
          type:
            - object
            - "null"
          additionalProperties: true
        responseId:
          type: string
    PlacesAutocompleteRequest:
      type: object
      required:
        - input
        - sessionToken
      properties:
        input:
          type: string
          minLength: 1
          maxLength: 256
        sessionToken:
          type: string
          minLength: 1
          maxLength: 128
        regionCode:
          type: string
          minLength: 2
          maxLength: 2
    PlacesAutocompleteSuggestion:
      type: object
      required:
        - placeId
        - primaryText
        - secondaryText
      properties:
        placeId:
          type: string
        primaryText:
          type: string
        secondaryText:
          type: string
    PlacesAutocompleteResult:
      type: object
      required:
        - suggestions
      properties:
        suggestions:
          type: array
          items:
            $ref: "#/components/schemas/PlacesAutocompleteSuggestion"
    UspsNearbyRequest:
      type: object
      required:
        - zip
      properties:
        zip:
          type: string
          minLength: 5
          maxLength: 10
          description: US ZIP code (5 digits, optional ZIP+4)
    UspsNearbyPlace:
      type: object
      required:
        - placeId
        - name
        - line1
        - city
        - state
        - zip
      properties:
        placeId:
          type: string
        name:
          type: string
        line1:
          type: string
        city:
          type: string
        state:
          type: string
        zip:
          type: string
    UspsNearbyResult:
      type: object
      required:
        - results
      properties:
        results:
          type: array
          items:
            $ref: "#/components/schemas/UspsNearbyPlace"
    MapCenterRequest:
      type: object
      required:
        - query
      properties:
        query:
          type: string
          minLength: 3
          maxLength: 400
          description: Free-text US address to center a map on
    MapCenterResult:
      type: object
      required:
        - lat
        - lng
      properties:
        lat:
          type: number
          description: WGS84 latitude
        lng:
          type: number
          description: WGS84 longitude
    Person:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type:
            - string
            - "null"
        email:
          type:
            - string
            - "null"
          format: email
        phone:
          type:
            - string
            - "null"
        city:
          type:
            - string
            - "null"
        state:
          type:
            - string
            - "null"
        date_of_birth:
          type:
            - string
            - "null"
        address_line1:
          type:
            - string
            - "null"
        address_line2:
          type:
            - string
            - "null"
        zip_code:
          type:
            - string
            - "null"
        country:
          type:
            - string
            - "null"
        client_id:
          type:
            - string
            - "null"
          format: uuid
        organization_id:
          type:
            - string
            - "null"
          format: uuid
        user_id:
          type:
            - string
            - "null"
          format: uuid
        role:
          type:
            - string
            - "null"
        profile_update_required:
          type:
            - boolean
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
        deleted_at:
          type:
            - string
            - "null"
          format: date-time
    CreatePersonRequest:
      type: object
      description: At least one of name, email, user_id, organization_id, or client_id is required. Organization attachment is
        optional.
      properties:
        name:
          type: string
        email:
          type: string
          format: email
        phone:
          type: string
        city:
          type: string
        state:
          type: string
        date_of_birth:
          type: string
        address_line1:
          type: string
        address_line2:
          type: string
        zip_code:
          type: string
        country:
          type: string
        client_id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
        user_id:
          type: string
          format: uuid
        role:
          type: string
    UpdatePersonRequest:
      type: object
      properties:
        name:
          type:
            - string
            - "null"
        email:
          type:
            - string
            - "null"
          format: email
        phone:
          type:
            - string
            - "null"
        city:
          type:
            - string
            - "null"
        state:
          type:
            - string
            - "null"
        date_of_birth:
          type:
            - string
            - "null"
        address_line1:
          type:
            - string
            - "null"
        address_line2:
          type:
            - string
            - "null"
        zip_code:
          type:
            - string
            - "null"
        country:
          type:
            - string
            - "null"
        client_id:
          type:
            - string
            - "null"
          format: uuid
        organization_id:
          type:
            - string
            - "null"
          format: uuid
        user_id:
          type:
            - string
            - "null"
          format: uuid
        role:
          type:
            - string
            - "null"
        profile_update_required:
          type:
            - boolean
            - "null"
    Product:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
        panel_id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
        price_cents:
          type: integer
        currency:
          type: string
          example: USD
        category:
          type:
            - string
            - "null"
        image_url:
          type:
            - string
            - "null"
        sku:
          type:
            - string
            - "null"
        status:
          type: string
          enum:
            - draft
            - live
            - archived
            - offline
        metadata:
          type:
            - object
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        panel:
          type:
            - object
            - "null"
          properties:
            id:
              type: string
              format: uuid
            name:
              type: string
            description:
              type:
                - string
                - "null"
            component_test_names:
              type: array
              items:
                type: string
    CreateProductRequest:
      type: object
      required:
        - organization_id
        - name
        - price_cents
        - currency
        - status
      properties:
        organization_id:
          type: string
          format: uuid
        panel_id:
          type: string
          format: uuid
        name:
          type: string
        price_cents:
          type: integer
        currency:
          type: string
          example: USD
        category:
          type: string
        image_url:
          type: string
        sku:
          type: string
        status:
          type: string
          enum:
            - draft
            - live
            - archived
            - offline
        metadata:
          type: object
    UpdateProductRequest:
      type: object
      properties:
        organization_id:
          type: string
          format: uuid
        panel_id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
        price_cents:
          type: integer
        currency:
          type: string
        category:
          type:
            - string
            - "null"
        image_url:
          type:
            - string
            - "null"
        sku:
          type:
            - string
            - "null"
        status:
          type: string
          enum:
            - draft
            - live
            - archived
            - offline
        metadata:
          type:
            - object
            - "null"
    Organization:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        org_type:
          type: string
          enum:
            - platform
            - client
            - lab
            - supplier
            - kitting
        status:
          type: string
          enum:
            - active
            - inactive
            - suspended
        settings:
          type:
            - object
            - "null"
        metadata:
          type:
            - object
            - "null"
        hero_title:
          type:
            - string
            - "null"
        logo_url:
          type:
            - string
            - "null"
        primary_color:
          type:
            - string
            - "null"
        accent_color:
          type:
            - string
            - "null"
        source_url:
          type:
            - string
            - "null"
        subdomain:
          type:
            - string
            - "null"
        custom_domain:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    CreateOrganizationRequest:
      type: object
      required:
        - name
        - org_type
      properties:
        name:
          type: string
        org_type:
          type: string
          enum:
            - platform
            - client
            - lab
            - supplier
            - kitting
        status:
          type: string
          enum:
            - active
            - inactive
            - suspended
        settings:
          type:
            - object
            - "null"
        metadata:
          type:
            - object
            - "null"
        hero_title:
          type:
            - string
            - "null"
        logo_url:
          type:
            - string
            - "null"
        primary_color:
          type:
            - string
            - "null"
        accent_color:
          type:
            - string
            - "null"
        source_url:
          type:
            - string
            - "null"
        subdomain:
          type:
            - string
            - "null"
        custom_domain:
          type:
            - string
            - "null"
    UpdateOrganizationRequest:
      type: object
      properties:
        name:
          type: string
        org_type:
          type: string
          enum:
            - platform
            - client
            - lab
            - supplier
            - kitting
        status:
          type: string
          enum:
            - active
            - inactive
            - suspended
        settings:
          type:
            - object
            - "null"
        metadata:
          type:
            - object
            - "null"
        hero_title:
          type:
            - string
            - "null"
        logo_url:
          type:
            - string
            - "null"
        primary_color:
          type:
            - string
            - "null"
        accent_color:
          type:
            - string
            - "null"
        source_url:
          type:
            - string
            - "null"
        subdomain:
          type:
            - string
            - "null"
        custom_domain:
          type:
            - string
            - "null"
    UpdateOrderRequest:
      type: object
      description: At least one field is required.
      properties:
        status:
          type: string
        payment_status:
          type: string
        tracking_number:
          type:
            - string
            - "null"
        amount_cents:
          type: integer
          minimum: 0
    UpdateOrderItemRequest:
      type: object
      properties:
        device_id:
          type:
            - string
            - "null"
          format: uuid
        quantity:
          type: integer
        price_cents:
          type: integer
        status:
          type: string
          enum:
            - pending
            - paid
            - processing
            - shipped
            - delivered
            - activated
            - collecting
            - lab_processing
            - results_ready
            - completed
            - cancelled
            - awaiting_drop_off
            - in_transit
            - delivered_to_lab
            - processing_at_lab
        activation_uid:
          type:
            - string
            - "null"
        tracking_number:
          type:
            - string
            - "null"
        carrier:
          type:
            - string
            - "null"
        tracking_url:
          type:
            - string
            - "null"
        shipped_at:
          type:
            - string
            - "null"
          format: date-time
        delivered_at:
          type:
            - string
            - "null"
          format: date-time
        activated_at:
          type:
            - string
            - "null"
          format: date-time
        return_tracking_number:
          type:
            - string
            - "null"
        return_tracking_carrier:
          type:
            - string
            - "null"
        return_tracking_url:
          type:
            - string
            - "null"
        return_label_url:
          type:
            - string
            - "null"
        return_label_issued_at:
          type:
            - string
            - "null"
          format: date-time
        return_shipped_at:
          type:
            - string
            - "null"
          format: date-time
        return_received_at:
          type:
            - string
            - "null"
          format: date-time
        metadata:
          type:
            - object
            - "null"
    BulkUpdateOrderItemsRequest:
      type: object
      required:
        - ids
        - updates
      properties:
        ids:
          type: array
          items:
            type: string
            format: uuid
          minItems: 1
        updates:
          $ref: "#/components/schemas/UpdateOrderItemRequest"
    OrderEvent:
      type: object
      properties:
        id:
          type: string
          format: uuid
        order_id:
          type: string
          format: uuid
        event_type:
          type: string
        status_after:
          type:
            - string
            - "null"
        headline:
          type:
            - string
            - "null"
        body:
          type:
            - string
            - "null"
        payload:
          type:
            - object
            - "null"
        created_at:
          type: string
          format: date-time
        created_by:
          type:
            - string
            - "null"
          format: uuid
    CreateOrderEventRequest:
      type: object
      required:
        - event_type
      properties:
        event_type:
          type: string
          minLength: 2
        status_after:
          type: string
        headline:
          type: string
        body:
          type: string
        payload:
          type: object
        shipping_update:
          type: object
          properties:
            tracking_number:
              type: string
            tracking_carrier:
              type: string
            tracking_url:
              type: string
            shipped_at:
              type: string
              format: date-time
            delivered_at:
              type: string
              format: date-time
            item_ids:
              type: array
              items:
                type: string
                format: uuid
        return_update:
          type: object
          properties:
            tracking_number:
              type: string
            tracking_carrier:
              type: string
            tracking_url:
              type: string
            shipped_at:
              type: string
              format: date-time
            received_at:
              type: string
              format: date-time
            label_url:
              type: string
            label_issued_at:
              type: string
              format: date-time
            item_ids:
              type: array
              items:
                type: string
                format: uuid
        lab_result_status:
          type: string
    OrderResult:
      type: object
      properties:
        id:
          type: string
          format: uuid
        order_id:
          type: string
          format: uuid
        summary:
          type:
            - string
            - "null"
        result_url:
          type:
            - string
            - "null"
        source_pdf_url:
          type:
            - string
            - "null"
        result_payload:
          type:
            - object
            - "null"
        released_at:
          type:
            - string
            - "null"
          format: date-time
        lab_org_id:
          type:
            - string
            - "null"
          format: uuid
        lab_result_status:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreateOrderResultRequest:
      type: object
      properties:
        summary:
          type: string
          maxLength: 5000
        result_url:
          type: string
          format: uri
        result_payload:
          type: object
        released_at:
          type: string
          format: date-time
        lab_org_id:
          type: string
          format: uuid
        lab_result_status:
          type: string
    OrderAssignment:
      type: object
      properties:
        id:
          type: string
          format: uuid
        order_id:
          type: string
          format: uuid
        assignment_type:
          type: string
          enum:
            - kitting
            - lab
        organization_id:
          type: string
          format: uuid
        assignee_person_id:
          type:
            - string
            - "null"
          format: uuid
        status:
          type: string
        instructions:
          type:
            - string
            - "null"
        tracking_number:
          type:
            - string
            - "null"
        tracking_carrier:
          type:
            - string
            - "null"
        tracking_url:
          type:
            - string
            - "null"
        metadata:
          type:
            - object
            - "null"
        completed_at:
          type:
            - string
            - "null"
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreateOrderAssignmentRequest:
      type: object
      required:
        - assignment_type
        - organization_id
      properties:
        assignment_type:
          type: string
          enum:
            - kitting
            - lab
        organization_id:
          type: string
          format: uuid
        assignee_person_id:
          type: string
          format: uuid
        status:
          type: string
        instructions:
          type: string
          maxLength: 2000
    UpdateOrderAssignmentRequest:
      type: object
      properties:
        status:
          type: string
        instructions:
          type: string
        tracking_number:
          type: string
        tracking_carrier:
          type: string
        tracking_url:
          type: string
        metadata:
          type: object
        mark_complete:
          type: boolean
        order_status:
          type: string
        shipping_update:
          type: object
        return_update:
          type: object
    ConnectorSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        displayName:
          type: string
        category:
          type: string
          enum:
            - lab
            - emr
            - billing
            - pharmacy
            - imaging
            - referral
            - logistics
            - crm
            - other
        transport:
          type: string
          enum:
            - rest_api
            - graphql
            - soap
            - sftp
            - hl7_mllp
            - fhir
            - webhook
            - email
            - manual
        scope:
          type: string
          enum:
            - global
            - override
        vendorName:
          type:
            - string
            - "null"
        vendorWebsite:
          type:
            - string
            - "null"
        requiresCredentials:
          type: boolean
        supportsSandbox:
          type: boolean
        description:
          type:
            - string
            - "null"
        metadata:
          type:
            - object
            - "null"
        updatedAt:
          type: string
          format: date-time
        versions:
          type: integer
        activeInstances:
          type: integer
    CreateConnectorRequest:
      type: object
      required:
        - name
        - display_name
        - category
        - transport
        - requires_credentials
        - supports_sandbox
      properties:
        name:
          type: string
          pattern: ^[a-z0-9_-]+$
        display_name:
          type: string
          minLength: 1
          maxLength: 100
        category:
          type: string
          enum:
            - lab
            - emr
            - billing
            - pharmacy
            - imaging
            - referral
            - logistics
            - crm
            - other
        transport:
          type: string
          enum:
            - rest_api
            - graphql
            - soap
            - sftp
            - hl7_mllp
            - fhir
            - webhook
            - email
            - manual
        description:
          type: string
        vendor_name:
          type: string
        vendor_website:
          type: string
          format: uri
        requires_credentials:
          type: boolean
        supports_sandbox:
          type: boolean
        metadata:
          type: object
    LabIngestObservation:
      type: object
      required:
        - sequence
        - code
        - description
      properties:
        sequence:
          type: integer
        code:
          type: string
        description:
          type: string
        valueType:
          type: string
        value:
          type: string
        unit:
          type: string
        referenceRange:
          type: string
        abnormal:
          type: boolean
        status:
          type: string
        observedAt:
          type: string
          format: date-time
        notes:
          type: array
          items:
            type: string
        attachment:
          type: object
          properties:
            type:
              type: string
            dataSubtype:
              type: string
            encoding:
              type: string
            data:
              type: string
    LabIngestResultsRequest:
      type: object
      required:
        - mode
        - connectorName
        - sourceFile
        - sourceSha256
        - parsed
      properties:
        mode:
          type: string
          enum:
            - results
        connectorName:
          type: string
        sourceFile:
          type: string
        sourceSha256:
          type: string
        clientCode:
          type: string
        parsed:
          type: object
          required:
            - msh
            - patient
            - order
            - report
            - observations
          properties:
            msh:
              type: object
              properties:
                messageType:
                  type: string
                messageControlId:
                  type: string
                version:
                  type: string
            patient:
              type: object
              required:
                - patientIds
              properties:
                patientIds:
                  type: array
                  items:
                    type: string
                name:
                  type: string
                dateOfBirth:
                  type: string
                sex:
                  type: string
                email:
                  type: string
                phone:
                  type: string
            order:
              type: object
              properties:
                placerOrderNumber:
                  type: string
                fillerOrderNumber:
                  type: string
                clientCode:
                  type: string
                orderingProvider:
                  type: string
            report:
              type: object
              properties:
                serviceId:
                  type: string
                serviceDescription:
                  type: string
                observationDateTime:
                  type: string
                  format: date-time
                reportDateTime:
                  type: string
                  format: date-time
            observations:
              type: array
              items:
                $ref: "#/components/schemas/LabIngestObservation"
            notes:
              type: array
              items:
                type: string
    LabIngestStatusRequest:
      type: object
      required:
        - mode
        - connectorName
        - sourceFile
        - sourceSha256
        - parsed
      properties:
        mode:
          type: string
          enum:
            - status
        connectorName:
          type: string
        sourceFile:
          type: string
        sourceSha256:
          type: string
        clientCode:
          type: string
        parsed:
          type: object
          required:
            - updates
          properties:
            updates:
              type: array
              items:
                type: object
                required:
                  - raw
                properties:
                  clientCode:
                    type: string
                  orderNumber:
                    type: string
                  trackingNumber:
                    type: string
                  carrier:
                    type: string
                  statusCode:
                    type: string
                  statusDescription:
                    type: string
                  occurredAt:
                    type: string
                    format: date-time
                  raw:
                    type: object
                    additionalProperties:
                      type: string
    LabIngestRequest:
      oneOf:
        - $ref: "#/components/schemas/LabIngestResultsRequest"
        - $ref: "#/components/schemas/LabIngestStatusRequest"
    LabIngestResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - disposition
            - summary
            - metadata
          properties:
            disposition:
              type: string
              enum:
                - archive
                - unmatched
            summary:
              type: string
            metadata:
              type: object
              additionalProperties: true
    LabHealthConnectorHealthResponse: &a1
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - connector
            - instances
            - recentTransactions
            - recentMessages
          properties:
            connector:
              oneOf:
                - $ref: "#/components/schemas/ConnectorSummary"
                - type: "null"
            instances:
              type: array
              items:
                type: object
                additionalProperties: true
            recentTransactions:
              type: array
              items:
                type: object
                additionalProperties: true
            recentMessages:
              type: array
              items:
                type: object
                additionalProperties: true
    ConnectorHealthResponse: *a1
    ConnectorFileRow:
      type: string
    ConnectorFilesResponse:
      type: object
      required:
        - data
      properties:
        data:
          type: object
          required:
            - recent
            - buckets
          properties:
            recent:
              type: array
              items:
                $ref: "#/components/schemas/ConnectorFileRow"
            buckets:
              type: object
              additionalProperties:
                type: array
                items:
                  $ref: "#/components/schemas/ConnectorFileRow"
    ConnectorFileActionRequest:
      type: object
      required:
        - action
        - bucket
        - filename
      properties:
        action:
          type: string
          enum:
            - requeue
            - delete
        bucket:
          type: string
          enum:
            - failed
            - unmatched
        filename:
          type: string
    TestSftpFileRequest:
      oneOf:
        - type: object
          required:
            - mode
          properties:
            mode:
              type: string
              enum:
                - sample
            sampleType:
              type: string
              enum:
                - hl7
                - status
              default: hl7
        - type: object
          required:
            - mode
            - filename
            - content
          properties:
            mode:
              type: string
              enum:
                - upload
            filename:
              type: string
              minLength: 1
              maxLength: 255
            content:
              type: string
              minLength: 1
              maxLength: 262144
              description: File content (max 256 KiB)
        - type: object
          required:
            - mode
          description: Real SSH/SFTP upload exercising the same path a partner job would hit. Provide sampleType OR (filename +
            content), exactly one.
          properties:
            mode:
              type: string
              enum:
                - simulate
            sampleType:
              type: string
              enum:
                - hl7
                - status
            filename:
              type: string
              minLength: 1
              maxLength: 255
            content:
              type: string
              minLength: 1
              maxLength: 262144
    TestSftpFileResponse:
      type: object
      required:
        - ok
      properties:
        ok:
          type: boolean
        mode:
          type: string
          enum:
            - sample
            - upload
            - simulate
        path:
          type: string
          description: Worker inbox path (sample/upload modes)
        trace:
          type: object
          description: Per-stage trace returned for simulate mode.
          required:
            - host
            - port
            - username
            - remoteDir
            - bytes
            - success
            - stage
            - startedAt
            - finishedAt
            - durationMs
            - timings
          properties:
            host:
              type: string
            port:
              type: integer
            username:
              type: string
            remoteDir:
              type: string
            remotePath:
              type:
                - string
                - "null"
            bytes:
              type: integer
            success:
              type: boolean
            stage:
              type: string
              enum:
                - dns
                - tcp
                - ssh_handshake
                - authenticate
                - chdir
                - upload
                - disconnect
            startedAt:
              type: string
              format: date-time
            finishedAt:
              type: string
              format: date-time
            durationMs:
              type: integer
            timings:
              type: object
              additionalProperties:
                type: integer
            error:
              type:
                - string
                - "null"
    SftpReachabilityResponse:
      type: object
      required:
        - host
        - port
        - reachable
        - latencyMs
      description: TCP reachability probe from the API host to the SFTP server, with DNS drift detection.
      properties:
        host:
          type: string
        port:
          type: integer
        advertisedIp:
          type:
            - string
            - "null"
          description: IP shared with partners for firewall whitelisting (from connector metadata).
        resolvedIp:
          type:
            - string
            - "null"
          description: IP the hostname resolves to right now.
        reachable:
          type: boolean
        latencyMs:
          type: integer
        error:
          type:
            - string
            - "null"
        ipMismatch:
          type:
            - object
            - "null"
          description: Set when advertisedIp differs from resolvedIp. Signals the whitelist info is stale.
          properties:
            advertised:
              type: string
            resolved:
              type: string
        note:
          type: string
    SftpHostKeyFingerprint:
      type: object
      required:
        - type
        - sha256
      properties:
        type:
          type: string
          enum:
            - ed25519
            - rsa
            - ecdsa
            - unknown
        sha256:
          type: string
          description: "SHA256 digest with SHA256: prefix"
        comment:
          type:
            - string
            - "null"
    SftpHostKeysData:
      type: object
      required:
        - keys
      properties:
        keys:
          type: array
          items:
            $ref: "#/components/schemas/SftpHostKeyFingerprint"
          description: Host public keys present on the SFTP worker
    SftpKeysResponse:
      type: object
      required:
        - keys
      properties:
        keys:
          type: array
          items:
            type: string
          description: Authorized SSH public keys (one per entry)
    SftpKeysUpdateRequest:
      type: object
      required:
        - keys
      properties:
        keys:
          type: array
          items:
            type: string
            maxLength: 2048
          maxItems: 50
          description: Full set of authorized SSH public keys to write
    SftpKeysUpdateResponse:
      type: object
      required:
        - ok
        - count
      properties:
        ok:
          type: boolean
        count:
          type: integer
          description: Number of keys saved
    CreateDemoActivationRequest:
      type: object
      required:
        - device_id
      properties:
        device_id:
          type: string
          format: uuid
          description: Target device — any row from /api/platform/devices.
    CreateDemoActivationResponse:
      type: object
      required:
        - activation_uid
        - order_id
        - order_item_id
        - device_id
        - device_name
        - expires_at
        - ttl_hours
      properties:
        activation_uid:
          type: string
          description: 24-char hex Kit ID the demo user pastes into the Kit Registration flow.
        order_id:
          type: string
          format: uuid
        order_item_id:
          type: string
          format: uuid
        device_id:
          type: string
          format: uuid
        device_name:
          type: string
        organization_id:
          type:
            - string
            - "null"
          format: uuid
        expires_at:
          type: string
          format: date-time
          description: When the demo order will be swept (4h after creation).
        ttl_hours:
          type: integer
          description: TTL applied to this demo activation.
    DemoDevice:
      type: object
      required:
        - id
        - name
      description: Slim device shape exposed to authenticated (non-platform) users via GET /api/demo-devices. Intentionally
        omits status, barcode_prefix, organization_id, and onboarding step counts.
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        organization:
          type:
            - object
            - "null"
          required:
            - name
          properties:
            name:
              type:
                - string
                - "null"
    DeviceActivation:
      type: object
      properties:
        id:
          type: string
          format: uuid
        activation_uid:
          type: string
        order_id:
          type:
            - string
            - "null"
          format: uuid
        device_id:
          type:
            - string
            - "null"
          format: uuid
        organization_id:
          type:
            - string
            - "null"
          format: uuid
        status:
          type: string
        activated_at:
          type:
            - string
            - "null"
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
        device_activation_steps:
          type: array
          items:
            $ref: "#/components/schemas/DeviceActivationStep"
    DeviceActivationConfirmRequest:
      type: object
      required:
        - activationUid
      properties:
        activationUid:
          type: string
    DeviceActivationConfirmResponse:
      type: object
      properties:
        success:
          type: boolean
        alreadyActivated:
          type: boolean
        activation:
          $ref: "#/components/schemas/DeviceActivation"
        steps:
          type: array
          items:
            $ref: "#/components/schemas/DeviceActivationStep"
        redirectPath:
          type: string
        branding:
          type:
            - object
            - "null"
    DeviceActivationStep:
      type: object
      properties:
        id:
          type: string
          format: uuid
        step_number:
          type: integer
        display_order:
          type: integer
        status:
          type: string
          enum:
            - pending
            - in_progress
            - completed
            - skipped
        title:
          type: string
        is_critical:
          type: boolean
        notes:
          type:
            - string
            - "null"
    UpdateDeviceActivationStepRequest:
      type: object
      required:
        - status
      properties:
        status:
          type: string
          enum:
            - pending
            - in_progress
            - completed
            - skipped
        notes:
          type:
            - string
            - "null"
    ReturnLabelInfo:
      type: object
      properties:
        return_label_url:
          type:
            - string
            - "null"
        return_tracking_number:
          type:
            - string
            - "null"
        return_tracking_carrier:
          type:
            - string
            - "null"
        return_tracking_url:
          type:
            - string
            - "null"
        return_label_issued_at:
          type:
            - string
            - "null"
          format: date-time
    EmailTemplate:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        subject:
          type: string
        body:
          type: string
        preview_text:
          type:
            - string
            - "null"
        cta_label:
          type:
            - string
            - "null"
        cta_url:
          type:
            - string
            - "null"
        footer_text:
          type:
            - string
            - "null"
        enabled:
          type: boolean
        organization_id:
          type:
            - string
            - "null"
          format: uuid
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreateEmailTemplateRequest:
      type: object
      required:
        - template_key
        - title
        - subject
        - body
      properties:
        template_key:
          type: string
          minLength: 1
          maxLength: 100
        title:
          type: string
          minLength: 1
          maxLength: 255
        subject:
          type: string
          minLength: 1
          maxLength: 255
        body:
          type: string
          minLength: 1
        preview_text:
          type: string
          maxLength: 255
        cta_label:
          type: string
          maxLength: 100
        cta_url:
          type: string
          maxLength: 500
        footer_text:
          type: string
        enabled:
          type: boolean
          default: true
        organization_id:
          type:
            - string
            - "null"
          format: uuid
    UpdateEmailTemplateRequest:
      type: object
      properties:
        title:
          type: string
          minLength: 1
          maxLength: 255
        subject:
          type: string
          minLength: 1
          maxLength: 255
        body:
          type: string
        preview_text:
          type: string
          maxLength: 255
        cta_label:
          type: string
          maxLength: 100
        cta_url:
          type: string
          maxLength: 500
        footer_text:
          type: string
        enabled:
          type: boolean
    EmailSendLog:
      type: object
      properties:
        id:
          type: string
          format: uuid
        template_id:
          type:
            - string
            - "null"
          format: uuid
        to_email:
          type: string
          format: email
        subject:
          type: string
        status:
          type: string
        sent_at:
          type: string
          format: date-time
        error:
          type:
            - string
            - "null"
    EducationalArticle:
      type: object
      properties:
        id:
          type: string
          format: uuid
        category_id:
          type: string
          format: uuid
        title:
          type: string
        slug:
          type: string
        summary:
          type:
            - string
            - "null"
        content:
          type:
            - string
            - "null"
        icon:
          type: string
        sort_order:
          type: integer
        is_published:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    EducationalArticleRelatedSummary:
      type: object
      properties:
        id:
          type: string
          format: uuid
        title:
          type: string
        slug:
          type: string
        summary:
          type:
            - string
            - "null"
        icon:
          type: string
        sort_order:
          type: integer
    EducationalArticleDetail:
      allOf:
        - $ref: "#/components/schemas/EducationalArticle"
        - type: object
          properties:
            category:
              nullable: true
              allOf:
                - $ref: "#/components/schemas/EducationalCategory"
              description: Joined `educational_categories` row when present
            related_articles:
              type: array
              description: Other published articles in the same category; empty when the article has no `category_id`.
              items:
                $ref: "#/components/schemas/EducationalArticleRelatedSummary"
    CreateArticleRequest:
      type: object
      required:
        - category_id
        - title
        - slug
        - icon
        - sort_order
        - is_published
      properties:
        category_id:
          type: string
          format: uuid
        title:
          type: string
        slug:
          type: string
        summary:
          type:
            - string
            - "null"
        content:
          type:
            - string
            - "null"
        icon:
          type: string
        sort_order:
          type: integer
        is_published:
          type: boolean
    EducationalCategory:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        slug:
          type: string
        description:
          type:
            - string
            - "null"
        icon:
          type: string
        sort_order:
          type: integer
        is_published:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreateCategoryRequest:
      type: object
      required:
        - name
        - slug
        - icon
        - sort_order
        - is_published
      properties:
        name:
          type: string
        slug:
          type: string
        description:
          type:
            - string
            - "null"
        icon:
          type: string
        sort_order:
          type: integer
        is_published:
          type: boolean
    EducationalVideo:
      type: object
      properties:
        id:
          type: string
          format: uuid
        category_id:
          type:
            - string
            - "null"
          format: uuid
        title:
          type: string
        description:
          type:
            - string
            - "null"
        video_url:
          type: string
          format: uri
        thumbnail_url:
          type:
            - string
            - "null"
          format: uri
        duration_seconds:
          type:
            - integer
            - "null"
        sort_order:
          type: integer
        is_published:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreateVideoRequest:
      type: object
      required:
        - title
        - video_url
        - sort_order
        - is_published
      properties:
        category_id:
          type:
            - string
            - "null"
          format: uuid
        title:
          type: string
        description:
          type:
            - string
            - "null"
        video_url:
          type: string
          format: uri
        thumbnail_url:
          type:
            - string
            - "null"
          format: uri
        duration_seconds:
          type:
            - integer
            - "null"
        sort_order:
          type: integer
        is_published:
          type: boolean
    EducationalContent:
      type: object
      properties:
        categories:
          type: array
          items:
            $ref: "#/components/schemas/EducationalCategory"
        articles:
          type: array
          items:
            $ref: "#/components/schemas/EducationalArticle"
        videos:
          type: array
          items:
            $ref: "#/components/schemas/EducationalVideo"
    BrandingInfo:
      type: object
      properties:
        client_name:
          type: string
        primary_color:
          type: string
        accent_color:
          type: string
        logo_url:
          type:
            - string
            - "null"
    BrandingMetricEntry:
      type: object
      properties:
        id:
          type: string
          format: uuid
        timestamp:
          type: string
          format: date-time
        duration_ms:
          type: integer
        url:
          type: string
        success:
          type: boolean
        error:
          type:
            - string
            - "null"
        method:
          type: string
        ai_confidence:
          type:
            - number
            - "null"
        logo_found:
          type: boolean
        colors_extracted:
          type: boolean
        hero_text_found:
          type: boolean
        address_found:
          type: boolean
        user_id:
          type:
            - string
            - "null"
          format: uuid
        created_at:
          type: string
          format: date-time
    BrandingMetricsStats:
      type: object
      properties:
        total:
          type: integer
        successful:
          type: integer
        failed:
          type: integer
        successRate:
          type: number
        avgDuration:
          type: number
        aiVisionCount:
          type: integer
        htmlFallbackCount:
          type: integer
        aiVisionRate:
          type: number
    StripeCheckoutRequest:
      type: object
      required:
        - email
        - amount
        - successUrl
        - cancelUrl
      properties:
        email:
          type: string
          format: email
        amount:
          type: integer
          minimum: 1
        successUrl:
          type: string
          format: uri
        cancelUrl:
          type: string
          format: uri
    StripeCheckoutResponse:
      type: object
      properties:
        sessionId:
          type: string
        url:
          type: string
          format: uri
    StripeVerifySessionRequest:
      type: object
      required:
        - sessionId
      properties:
        sessionId:
          type: string
    StripeVerifySessionResponse:
      type: object
      properties:
        verified:
          type: boolean
        session:
          type: object
          properties:
            id:
              type: string
            payment_status:
              type: string
            status:
              type: string
            customer_email:
              type:
                - string
                - "null"
        order:
          $ref: "#/components/schemas/Order"
    TestPanel:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        category_id:
          type:
            - string
            - "null"
          format: uuid
        component_test_names:
          type: array
          items:
            type: string
        test_component_count:
          type: integer
        status:
          type:
            - string
            - "null"
          enum:
            - active
            - inactive
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreateTestPanelRequest:
      type: object
      required:
        - organization_id
        - name
        - component_test_names
      properties:
        organization_id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        category_id:
          type:
            - string
            - "null"
          format: uuid
        component_test_names:
          type: array
          items:
            type: string
          minItems: 1
    PlatformUser:
      type: object
      properties:
        id:
          type: string
          format: uuid
        user_id:
          type: string
          format: uuid
        role:
          type: string
        client_id:
          type:
            - string
            - "null"
          format: uuid
        organization_name:
          type:
            - string
            - "null"
        email:
          type: string
          format: email
        name:
          type:
            - string
            - "null"
        last_sign_in_at:
          type:
            - string
            - "null"
          format: date-time
        email_confirmed_at:
          type:
            - string
            - "null"
          format: date-time
        invited_at:
          type:
            - string
            - "null"
          format: date-time
        has_accepted_consent:
          type: boolean
        consent_accepted_at:
          type:
            - string
            - "null"
          format: date-time
        consent_version:
          type:
            - string
            - "null"
        is_active:
          type: boolean
        profile_required:
          type: boolean
        first_name:
          type:
            - string
            - "null"
        last_name:
          type:
            - string
            - "null"
        banned_until:
          type:
            - string
            - "null"
          format: date-time
        phone:
          type:
            - string
            - "null"
        address_line1:
          type:
            - string
            - "null"
        address_line2:
          type:
            - string
            - "null"
        city:
          type:
            - string
            - "null"
        state:
          type:
            - string
            - "null"
        zip_code:
          type:
            - string
            - "null"
        country:
          type:
            - string
            - "null"
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreatePlatformUserRequest:
      type: object
      required:
        - email
        - role
      properties:
        email:
          type: string
          format: email
        role:
          type: string
        client_id:
          type:
            - string
            - "null"
          format: uuid
    UpdatePlatformUserRequest:
      type: object
      required:
        - user_id
      properties:
        user_id:
          type: string
        name:
          type: string
        role:
          type: string
        client_id:
          type:
            - string
            - "null"
        is_active:
          type: boolean
        profile_update_required:
          type: boolean
        phone:
          type:
            - string
            - "null"
        address_line1:
          type:
            - string
            - "null"
        address_line2:
          type:
            - string
            - "null"
        city:
          type:
            - string
            - "null"
        state:
          type:
            - string
            - "null"
        zip_code:
          type:
            - string
            - "null"
        country:
          type:
            - string
            - "null"
    InviteUserRequest:
      type: object
      required:
        - email
        - role
      properties:
        email:
          type: string
          format: email
        role:
          type: string
        client_id:
          type:
            - string
            - "null"
          format: uuid
        password:
          type: string
          minLength: 8
        send_activation_email:
          type: boolean
    AssignRoleRequest:
      type: object
      required:
        - role
      properties:
        role:
          type: string
        client_id:
          type:
            - string
            - "null"
          format: uuid
    CheckPermissionsResponse:
      type: object
      properties:
        isPlatformEmployee:
          type: boolean
        email:
          type: string
          format: email
        role:
          type:
            - string
            - "null"
    Device:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organization_id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        device_type:
          type: string
        barcode_prefix:
          type:
            - string
            - "null"
        status:
          type: string
          enum:
            - active
            - inactive
            - discontinued
        onboarding_step_count:
          type: integer
        archived_at:
          type:
            - string
            - "null"
          format: date-time
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreateDeviceRequest:
      type: object
      required:
        - name
        - device_type
      description: organization_id is optional; omit or null for platform-global devices.
      properties:
        organization_id:
          type:
            - string
            - "null"
          format: uuid
        name:
          type: string
        description:
          type:
            - string
            - "null"
        device_type:
          type: string
        barcode_prefix:
          type:
            - string
            - "null"
        status:
          type: string
          enum:
            - active
            - inactive
            - discontinued
    DeviceTemplate:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        device_type:
          type: string
        device_onboarding_steps:
          type: array
          items:
            type: object
            properties:
              id:
                type: string
                format: uuid
              step_number:
                type: integer
              display_order:
                type: integer
              title:
                type: string
              is_critical:
                type: boolean
    DeviceOnboardingStep:
      type: object
      properties:
        id:
          type: string
          format: uuid
        device_id:
          type:
            - string
            - "null"
          format: uuid
        template_id:
          type:
            - string
            - "null"
          format: uuid
        step_number:
          type: integer
        display_order:
          type: integer
        title:
          type: string
        description:
          type: string
        image_url:
          type:
            - string
            - "null"
        is_required:
          type: boolean
        metadata:
          type: object
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    QuestionnaireQuestion:
      type: object
      properties:
        id:
          type: string
          format: uuid
        template_id:
          type: string
          format: uuid
        parent_question_id:
          type:
            - string
            - "null"
          format: uuid
        parent_question_key:
          type:
            - string
            - "null"
        question_key:
          type: string
        prompt:
          type: string
        help_text:
          type:
            - string
            - "null"
        question_type:
          type: string
          enum:
            - text
            - number
            - yes_no
            - single_select
            - multi_select
            - compound
        options:
          type: array
          items: {}
        sub_fields:
          type: array
          items: {}
        is_required:
          type: boolean
        display_order:
          type: integer
        metadata:
          type: object
          additionalProperties: true
    QuestionnaireTemplate:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        type:
          type: string
          enum:
            - pre_draw
            - post_draw
            - intake
            - follow_up
        description:
          type:
            - string
            - "null"
        is_active:
          type: boolean
        metadata:
          type: object
          additionalProperties: true
        created_by:
          type:
            - string
            - "null"
          format: uuid
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
        questionnaire_questions:
          type: array
          items:
            $ref: "#/components/schemas/QuestionnaireQuestion"
    CreateQuestionnaireTemplateRequest:
      type: object
      required:
        - name
        - type
        - questions
      properties:
        name:
          type: string
          minLength: 1
        type:
          type: string
          enum:
            - pre_draw
            - post_draw
            - intake
            - follow_up
        description:
          type:
            - string
            - "null"
        is_active:
          type: boolean
        metadata:
          type: object
          additionalProperties: true
        questions:
          type: array
          minItems: 1
          items:
            type: object
            required:
              - question_key
              - prompt
              - question_type
            properties:
              question_key:
                type: string
                minLength: 1
              prompt:
                type: string
                minLength: 1
              help_text:
                type:
                  - string
                  - "null"
              question_type:
                type: string
                enum:
                  - text
                  - number
                  - yes_no
                  - single_select
                  - multi_select
                  - compound
              options:
                type: array
                items: {}
              sub_fields:
                type: array
                items: {}
              is_required:
                type: boolean
              display_order:
                type: integer
              metadata:
                type: object
                additionalProperties: true
              parent_question_key:
                type:
                  - string
                  - "null"
    UpdateQuestionnaireTemplateRequest:
      type: object
      properties:
        name:
          type: string
          minLength: 1
        type:
          type: string
          enum:
            - pre_draw
            - post_draw
            - intake
            - follow_up
        description:
          type:
            - string
            - "null"
        is_active:
          type: boolean
        metadata:
          type: object
          additionalProperties: true
        questions:
          type: array
          minItems: 1
          items:
            type: object
            required:
              - question_key
              - prompt
              - question_type
            properties:
              question_key:
                type: string
                minLength: 1
              prompt:
                type: string
                minLength: 1
              help_text:
                type:
                  - string
                  - "null"
              question_type:
                type: string
                enum:
                  - text
                  - number
                  - yes_no
                  - single_select
                  - multi_select
                  - compound
              options:
                type: array
                items: {}
              sub_fields:
                type: array
                items: {}
              is_required:
                type: boolean
              display_order:
                type: integer
              metadata:
                type: object
                additionalProperties: true
              parent_question_key:
                type:
                  - string
                  - "null"
    QuestionnaireResponse:
      type: object
      properties:
        id:
          type: string
          format: uuid
        template_id:
          type: string
          format: uuid
        person_id:
          type: string
          format: uuid
        order_id:
          type:
            - string
            - "null"
          format: uuid
        responses:
          type: array
          items: {}
        completed_at:
          type:
            - string
            - "null"
          format: date-time
        created_by:
          type:
            - string
            - "null"
          format: uuid
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    CreateQuestionnaireResponseRequest:
      type: object
      required:
        - template_id
        - responses
      properties:
        template_id:
          type: string
          format: uuid
        order_id:
          type:
            - string
            - "null"
          format: uuid
        responses:
          type: array
          minItems: 1
          items: {}
        completed_at:
          type:
            - string
            - "null"
          format: date-time
    PortalActionItem:
      type: object
      properties:
        id:
          type: string
          format: uuid
        person_id:
          type: string
          format: uuid
        order_id:
          type:
            - string
            - "null"
          format: uuid
        action_type:
          type: string
          enum:
            - activate_kit
            - complete_questionnaire
            - ship_sample
            - view_instructions
            - complete_profile
        title:
          type: string
        description:
          type:
            - string
            - "null"
        status:
          type: string
          enum:
            - pending
            - completed
        display_order:
          type: integer
        due_at:
          type:
            - string
            - "null"
          format: date-time
        completed_at:
          type:
            - string
            - "null"
          format: date-time
        is_auto_generated:
          type: boolean
        metadata:
          type: object
        action_href:
          type: string
          description: Suggested portal path for this action (HO-363)
        icon:
          type: string
          description: Suggested icon name for UI
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    UpdatePortalActionItemRequest:
      type: object
      required:
        - id
        - status
      properties:
        id:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - pending
            - completed
    ActionItemTemplate:
      type: object
      properties:
        id:
          type: string
          format: uuid
        action_type:
          type: string
          enum:
            - activate_kit
            - complete_questionnaire
            - ship_sample
            - view_instructions
        title:
          type: string
        description:
          type: string
        display_order:
          type: integer
        is_active:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    UpdateActionItemTemplateRequest:
      type: object
      required:
        - action_type
      properties:
        action_type:
          type: string
          enum:
            - activate_kit
            - complete_questionnaire
            - ship_sample
            - view_instructions
        title:
          type: string
          minLength: 1
          maxLength: 200
        description:
          type: string
          maxLength: 1000
        display_order:
          type: integer
          minimum: 0
        is_active:
          type: boolean
    BulkUpdateActionItemTemplatesRequest:
      type: array
      minItems: 1
      items:
        type: object
        required:
          - action_type
          - title
        properties:
          action_type:
            type: string
            enum:
              - activate_kit
              - complete_questionnaire
              - ship_sample
              - view_instructions
          title:
            type: string
            minLength: 1
            maxLength: 200
          description:
            type: string
            maxLength: 1000
          display_order:
            type: integer
            minimum: 0
          is_active:
            type: boolean
    UpdatePlatformUserActionItemRequest:
      type: object
      properties:
        status:
          type: string
          enum:
            - pending
            - completed
        title:
          type: string
          minLength: 1
          maxLength: 200
        description:
          type: string
          maxLength: 1000
        display_order:
          type: integer
          minimum: 0
    PlatformUserActionItem:
      type: object
      properties:
        id:
          type: string
        title:
          type: string
        status:
          type: string
          enum:
            - completed
            - pending
            - not_applicable
        completed_at:
          type:
            - string
            - "null"
          format: date-time
        mandatory:
          type: boolean
        blocks_portal_nav:
          type: boolean
    PlatformUserActionItemsResponse:
      type: object
      required:
        - items
        - summary
      properties:
        items:
          type: array
          items:
            $ref: "#/components/schemas/PlatformUserActionItem"
        summary:
          type: object
          properties:
            total:
              type: integer
            completed:
              type: integer
            pending:
              type: integer
    PlatformRole:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        display_name:
          type: string
        description:
          type:
            - string
            - "null"
        redirect_url:
          type:
            - string
            - "null"
        hierarchy_level:
          type: integer
    CreateRoleRequest:
      type: object
      required:
        - name
        - display_name
        - redirect_url
      properties:
        name:
          type: string
          pattern: ^[a-z][a-z0-9_]*$
        display_name:
          type: string
        description:
          type: string
        redirect_url:
          type: string
        is_active:
          type: boolean
        parent_role_id:
          type:
            - string
            - "null"
          format: uuid
    UpdateRoleRequest:
      type: object
      properties:
        display_name:
          type: string
        description:
          type: string
        redirect_url:
          type: string
    RoleStats:
      type: object
      properties:
        id:
          type: string
          format: uuid
        role:
          type: string
        label:
          type: string
        description:
          type:
            - string
            - "null"
        redirect_url:
          type:
            - string
            - "null"
        count:
          type: integer
    PanelCategory:
      type: object
      properties:
        id:
          type: string
          format: uuid
        organization_id:
          type: string
          format: uuid
        name:
          type: string
        slug:
          type: string
        description:
          type:
            - string
            - "null"
        display_order:
          type: integer
        is_active:
          type: boolean
        created_at:
          type: string
          format: date-time
        updated_at:
          type:
            - string
            - "null"
          format: date-time
    CreatePanelCategoryRequest:
      type: object
      required:
        - organization_id
        - name
        - slug
      properties:
        organization_id:
          type: string
          format: uuid
        name:
          type: string
        slug:
          type: string
        description:
          type:
            - string
            - "null"
        display_order:
          type: integer
        is_active:
          type: boolean
    PlatformSetting:
      type: object
      properties:
        key:
          type: string
        category:
          type: string
        type:
          type: string
        value: {}
        value_envelope:
          type: object
        description:
          type:
            - string
            - "null"
        updated_at:
          type: string
          format: date-time
        updated_by:
          type: string
          format: uuid
        updated_by_email:
          type: string
        updated_by_name:
          type: string
    CreateSettingRequest:
      type: object
      required:
        - key
        - value
      properties:
        key:
          type: string
        value: {}
        type:
          type: string
        category:
          type: string
        description:
          type:
            - string
            - "null"
    ConsentSigningUrlRequest:
      type: object
      properties:
        person_id:
          type: string
          format: uuid
        return_url:
          type: string
    ConsentConfig:
      type: object
      properties:
        provider:
          type: string
        consent_required:
          type: boolean
        consent_version:
          type: string
        docusign_enabled:
          type: boolean
        onboardingStep:
          type: integer
          description: Onboarding step index for grouping consents (e.g. 1 = Step 1)
        items:
          type: array
          description: Array of consent items for checkbox UI (if available)
          items:
            type: object
            properties:
              id:
                type: string
                description: Unique consent item ID
              title:
                type: string
                description: Consent item title (e.g. "HIPAA Authorization")
              description:
                type: string
                description: Short description of the item
              content:
                type: string
                description: Full content (HTML or plaintext)
              required:
                type: boolean
                description: Whether this item is required
              display_order:
                type: integer
                description: Display order for rendering
    CreateTestOrdersRequest:
      type: object
      properties:
        email:
          type: string
          format: email
        count:
          type: integer
          minimum: 1
          maximum: 10
        skipEmails:
          type: boolean
    BulkDeleteRequest:
      type: object
      required:
        - ids
      properties:
        ids:
          type: array
          items:
            type: string
            format: uuid
          minItems: 1
          maxItems: 100
    DeleteByIdRequest:
      type: object
      required:
        - id
      properties:
        id:
          type: string
          format: uuid
    LogEntry:
      type: object
      properties:
        level:
          type: string
        message:
          type: string
        timestamp:
          type: string
          format: date-time
        metadata:
          type: object
    MetricEntry:
      type: object
      properties:
        name:
          type: string
        value:
          type: number
        tags:
          type: object
        timestamp:
          type: string
          format: date-time
    ImpersonateRequest:
      type: object
      properties:
        reason:
          type: string
          description: Optional reason for impersonation (logged for audit)
    EmailCheckResponse:
      type: object
      required:
        - email_exists
      properties:
        email_exists:
          type: boolean
          description: True if an account exists for the given email
    KitActivationInfo:
      type: object
      required:
        - activation
      properties:
        activation:
          type: object
          required:
            - activation_uid
            - status
            - already_activated
            - order_item_status
            - order
            - panels
          properties:
            activation_uid:
              type: string
            status:
              type: string
              enum:
                - pending
                - in_progress
                - activated
            already_activated:
              type: boolean
            order_item_status:
              type: string
            device:
              oneOf:
                - type: object
                  properties:
                    name:
                      type: string
                    device_type:
                      type: string
                    description:
                      type:
                        - string
                        - "null"
                - type: "null"
            order:
              type: object
              required:
                - order_number
                - organization
              properties:
                order_number:
                  type: string
                organization:
                  type: object
                  required:
                    - name
                  properties:
                    name:
                      type: string
                    logo_url:
                      type:
                        - string
                        - "null"
                    primary_color:
                      type:
                        - string
                        - "null"
                    accent_color:
                      type:
                        - string
                        - "null"
            panels:
              type: array
              items:
                type: object
                required:
                  - panel_name
                properties:
                  panel_name:
                    type: string
                  panel_description:
                    type:
                      - string
                      - "null"
    KitLookupResponse:
      type: object
      required:
        - activation
        - email_exists
      properties:
        activation:
          type: object
          required:
            - activation_uid
            - status
            - organization
            - panels
          properties:
            id:
              type:
                - string
                - "null"
              format: uuid
              description: device_activation record ID, null if not yet started
            activation_uid:
              type: string
            status:
              type: string
              enum:
                - pending
                - in_progress
                - activated
            device:
              oneOf:
                - type: object
                  properties:
                    name:
                      type: string
                    device_type:
                      type: string
                    description:
                      type:
                        - string
                        - "null"
                - type: "null"
            organization:
              type: object
              required:
                - name
              properties:
                name:
                  type: string
                logo_url:
                  type:
                    - string
                    - "null"
                primary_color:
                  type:
                    - string
                    - "null"
                accent_color:
                  type:
                    - string
                    - "null"
            panels:
              type: array
              items:
                type: object
                required:
                  - panel_name
                properties:
                  panel_name:
                    type: string
                  panel_description:
                    type:
                      - string
                      - "null"
                  biomarkers:
                    type: array
                    items:
                      type: string
                    description: Component test names from test_panels
        email_exists:
          oneOf:
            - type: boolean
            - type: "null"
          description: Whether an account exists for the provided email. null if no email was supplied.
    KitAgreementsResponse:
      type: object
      required:
        - activation_uid
        - organization_id
        - agreements
      properties:
        activation_uid:
          type: string
        organization_id:
          type: string
          format: uuid
        agreements:
          type: array
          items:
            type: object
            required:
              - id
              - label
              - required
            properties:
              id:
                type: string
              label:
                type: string
              description:
                type:
                  - string
                  - "null"
              required:
                type: boolean
    KitRegisterRequest:
      type: object
      required:
        - activation_uid
      properties:
        activation_uid:
          type: string
          minLength: 10
        agreements:
          description: Agreement selections; accepted as object map or item array.
          oneOf:
            - type: object
              additionalProperties:
                type: boolean
            - type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                  accepted:
                    type: boolean
                  agreement_id:
                    type: string
                  agreementId:
                    type: string
                  checked:
                    type: boolean
                  value:
                    type: boolean
        agreementSelections:
          description: Legacy alias for agreements payload.
          oneOf:
            - type: object
              additionalProperties:
                type: boolean
            - type: array
              items:
                type: object
                properties:
                  id:
                    type: string
                  accepted:
                    type: boolean
                  agreement_id:
                    type: string
                  agreementId:
                    type: string
                  checked:
                    type: boolean
                  value:
                    type: boolean
    KitRegisterResponse:
      type: object
      required:
        - success
        - activation_uid
        - organization_id
        - accepted_agreement_ids
      properties:
        success:
          type: boolean
        activation_uid:
          type: string
        organization_id:
          type: string
          format: uuid
        accepted_agreement_ids:
          type: array
          items:
            type: string
    CourierPickupAddress:
      type: object
      required:
        - line1
        - city
        - state
        - zip
      properties:
        line1:
          type: string
        line2:
          type: string
          nullable: true
        city:
          type: string
        state:
          type: string
        zip:
          type: string
        phone:
          type: string
          nullable: true
        name:
          type: string
          nullable: true
    CourierPickupQuote:
      type: object
      required:
        - id
        - pickupAddress
        - dropoffAddress
      properties:
        id:
          type: string
          format: uuid
        estimatedFeeCents:
          type: integer
          nullable: true
        currency:
          type: string
          example: USD
        estimatedPickupMinutes:
          type: integer
          nullable: true
        pickupAddress:
          $ref: "#/components/schemas/CourierPickupAddress"
        dropoffAddress:
          $ref: "#/components/schemas/CourierPickupAddress"
    CourierPickupStatus:
      type: object
      required:
        - id
        - status
      properties:
        id:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - pending
            - quoted
            - requested
            - pickup_en_route
            - picked_up
            - dropoff_en_route
            - delivered
            - cancelled
            - failed
        uberTrackingUrl:
          type: string
          format: uri
          nullable: true
        pickupAddress:
          $ref: "#/components/schemas/CourierPickupAddress"
        dropoffAddress:
          $ref: "#/components/schemas/CourierPickupAddress"
        quotedFeeCents:
          type: integer
          nullable: true
        currency:
          type: string
        pickupWindowStart:
          type: string
          format: date-time
          nullable: true
        pickupWindowEnd:
          type: string
          format: date-time
          nullable: true
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    CourierPickupConfirm:
      type: object
      required:
        - id
        - status
      properties:
        id:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - requested
        uberTrackingUrl:
          type: string
          format: uri
          nullable: true
        estimatedPickup:
          type: string
          format: date-time
          nullable: true
    CourierPickupCancel:
      type: object
      required:
        - id
        - status
      properties:
        id:
          type: string
          format: uuid
        status:
          type: string
          enum:
            - cancelled
paths:
  /api/auth/redirect:
    get:
      operationId: getAuthRedirect
      summary: List Auth Redirect
      tags:
        - Auth
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Auth Redirect
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/auth/reset-password:
    patch:
      operationId: updateAuthResetPassword
      summary: Update Auth Reset Password
      tags:
        - Auth
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePasswordRequest"
      responses:
        "200":
          description: Update Auth Reset Password
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: requestPasswordReset
      summary: Request password reset
      tags:
        - Auth
      description: >-
        Triggers a password reset email. Always returns 200 to prevent email enumeration.

        Rate limited (10/15min per IP). The recovery link redirects to /reset-password unless redirectTo targets that
        path (or legacy /auth/reset-password) on an allowed origin.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ResetPasswordRequest"
      responses:
        "200":
          description: Reset email sent (or generic message)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      message:
                        type: string
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/biomarker-history/{personId}:
    get:
      operationId: getBiomarkerHistoryByPersonId
      summary: Get Biomarker History by ID
      tags:
        - BiomarkerHistory
      security:
        - BearerAuth: []
      parameters:
        - name: personId
          in: path
          required: true
          schema:
            type: string
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: Get Biomarker History by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Biomarker"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/biomarker-history:
    get:
      operationId: getBiomarkerHistory
      summary: List Biomarker History
      tags:
        - BiomarkerHistory
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Biomarker History
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/BiomarkerHistoryGroupedEnvelope"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/branding/metrics:
    get:
      operationId: getBrandingMetrics
      summary: List Branding Metrics
      tags:
        - Branding
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Branding Metrics
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/BrandingMetricsStats"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/branding:
    get:
      operationId: getBranding
      summary: List Branding
      tags:
        - Branding
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Branding
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/BrandingInfo"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/connectors/{id}:
    get:
      operationId: getConnectorsById
      summary: Get Connectors by ID
      tags:
        - Connectors
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Connectors by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConnectorSummary"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updateConnectorsById
      summary: Update Connectors
      tags:
        - Connectors
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateConnectorRequest"
      responses:
        "200":
          description: Update Connectors
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConnectorSummary"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteConnectorsById
      summary: Delete Connectors
      tags:
        - Connectors
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: &a2
                type: object
                required:
                  - success
                properties:
                  success:
                    type: boolean
                    enum:
                      - true
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/connectors:
    get:
      operationId: getConnectors
      summary: List Connectors
      tags:
        - Connectors
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
        - name: organization_id
          in: query
          required: false
          schema:
            type: string
          description: Filter by organization ID
      responses:
        "200":
          description: List Connectors
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ConnectorSummary"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createConnectors
      summary: Create Connectors
      tags:
        - Connectors
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateConnectorRequest"
      responses:
        "200":
          description: Create Connectors
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConnectorSummary"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/consent/config:
    get:
      operationId: getConsentConfig
      summary: List Consent Config
      tags:
        - Consent
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Consent Config
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConsentConfig"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/consent/signing-url:
    post:
      operationId: createConsentSigningUrl
      summary: Create Consent Signing Url
      tags:
        - Consent
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ConsentSigningUrlRequest"
      responses:
        "200":
          description: Create Consent Signing Url
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/debug/tables/{tableName}/purge:
    delete:
      operationId: deleteDebugTablesByTableNamePurge
      summary: Delete Debug Tables Purge
      tags:
        - Internal
      security:
        - BearerAuth: []
      parameters:
        - name: tableName
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/debug/tables/{tableName}:
    get:
      operationId: getDebugTablesByTableName
      summary: Get Debug Tables by ID
      tags:
        - Internal
      security:
        - BearerAuth: []
      parameters:
        - name: tableName
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Debug Tables by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/debug/tables:
    get:
      operationId: getDebugTables
      summary: List Debug Tables
      tags:
        - Internal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Debug Tables
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/demo-devices:
    get:
      operationId: getDemoDevices
      summary: List Demo Devices
      tags:
        - Demo-devices
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Demo Devices
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/DemoDevice"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/demo/checkout:
    post:
      operationId: createDemoCheckout
      summary: Create Demo Checkout
      tags:
        - Internal
      security:
        - ServiceRoleKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StripeCheckoutRequest"
      responses:
        "200":
          description: Create Demo Checkout
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/StripeCheckoutResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/design-system/analyze:
    get:
      operationId: getDesignSystemAnalyze
      summary: List Design System Analyze
      tags:
        - Internal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Design System Analyze
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/educational/articles/{id}:
    get:
      operationId: getEducationalArticlesById
      summary: Get Educational Articles by ID
      tags:
        - Educational
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Educational Articles by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalArticleDetail"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updateEducationalArticlesById
      summary: Update Educational Articles
      tags:
        - Educational
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateArticleRequest"
      responses:
        "200":
          description: Update Educational Articles
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalArticle"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteEducationalArticlesById
      summary: Delete Educational Articles
      tags:
        - Educational
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/educational/articles:
    post:
      operationId: createEducationalArticles
      summary: Create Educational Articles
      tags:
        - Educational
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateArticleRequest"
      responses:
        "200":
          description: Create Educational Articles
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalArticle"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/educational/categories/{id}:
    patch:
      operationId: updateEducationalCategoriesById
      summary: Update Educational Categories
      tags:
        - Educational
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCategoryRequest"
      responses:
        "200":
          description: Update Educational Categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalCategory"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteEducationalCategoriesById
      summary: Delete Educational Categories
      tags:
        - Educational
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/educational/categories:
    post:
      operationId: createEducationalCategories
      summary: Create Educational Categories
      tags:
        - Educational
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCategoryRequest"
      responses:
        "200":
          description: Create Educational Categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalCategory"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/educational:
    get:
      operationId: getEducational
      summary: List Educational
      tags:
        - Educational
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Educational
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalContent"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/educational/videos/{id}:
    patch:
      operationId: updateEducationalVideosById
      summary: Update Educational Videos
      tags:
        - Educational
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateVideoRequest"
      responses:
        "200":
          description: Update Educational Videos
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalVideo"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteEducationalVideosById
      summary: Delete Educational Videos
      tags:
        - Educational
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/educational/videos:
    post:
      operationId: createEducationalVideos
      summary: Create Educational Videos
      tags:
        - Educational
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateVideoRequest"
      responses:
        "200":
          description: Create Educational Videos
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalVideo"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/email-send-logs:
    get:
      operationId: getEmailSendLogs
      summary: List Email Send Logs
      tags:
        - EmailTemplates
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
        - name: template_id
          in: query
          required: false
          schema:
            type: string
          description: Filter by email template ID
        - name: status
          in: query
          required: false
          schema:
            type: string
          description: Filter by send status
      responses:
        "200":
          description: List Email Send Logs
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/EmailSendLog"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createEmailSendLogs
      summary: Create Email Send Logs
      tags:
        - EmailTemplates
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/EmailSendLog"
      responses:
        "200":
          description: Create Email Send Logs
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/email-templates/{id}:
    get:
      operationId: getEmailTemplatesById
      summary: Get Email Templates by ID
      tags:
        - EmailTemplates
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Email Templates by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EmailTemplate"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updateEmailTemplatesById
      summary: Update Email Templates
      tags:
        - EmailTemplates
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateEmailTemplateRequest"
      responses:
        "200":
          description: Update Email Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EmailTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteEmailTemplatesById
      summary: Delete Email Templates
      tags:
        - EmailTemplates
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/email-templates:
    get:
      operationId: getEmailTemplates
      summary: List Email Templates
      tags:
        - EmailTemplates
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Email Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/EmailTemplate"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createEmailTemplates
      summary: Create Email Templates
      tags:
        - EmailTemplates
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateEmailTemplateRequest"
      responses:
        "200":
          description: Create Email Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EmailTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/health/email:
    get:
      operationId: getHealthEmail
      summary: List Health Email
      tags:
        - Public
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Health Email
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EmailHealthStatus"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/lab-ingest:
    post:
      operationId: createLabIngest
      summary: Create Lab Ingest
      tags:
        - Lab-ingest
      security:
        - ServiceRoleKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LabIngestRequest"
      responses:
        "200":
          description: Create Lab Ingest
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/LabIngestResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/lovable/database:
    get:
      operationId: getLovableDatabase
      summary: List Lovable Database
      tags:
        - Lovable
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Lovable Database
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
  /api/lovable/feedback:
    post:
      operationId: createLovableFeedback
      summary: Create Lovable Feedback
      tags:
        - Lovable
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Lovable Feedback
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/lovable/schema:
    get:
      operationId: getLovableSchema
      summary: List Lovable Schema
      tags:
        - Lovable
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Lovable Schema
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
  /api/metrics:
    get:
      operationId: getMetrics
      summary: List Metrics
      tags:
        - Internal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Metrics
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/MetricEntry"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createMetrics
      summary: Create Metrics
      tags:
        - Internal
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MetricEntry"
      responses:
        "200":
          description: Create Metrics
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/openapi:
    get:
      operationId: getOpenapi
      summary: List Openapi
      tags:
        - Public
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Openapi
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
  /api/orders/{id}/assignments/{assignmentId}:
    patch:
      operationId: updateOrdersByIdAssignmentsByAssignmentId
      summary: Update Orders Assignments
      tags:
        - Orders
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: assignmentId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateOrderAssignmentRequest"
      responses:
        "200":
          description: Update Orders Assignments
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/OrderAssignment"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/orders/{id}/assignments:
    get:
      operationId: getOrdersByIdAssignments
      summary: Get Orders Assignments by ID
      tags:
        - Orders
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: Get Orders Assignments by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/OrderAssignment"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createOrdersByIdAssignments
      summary: Create Orders Assignments
      tags:
        - Orders
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateOrderAssignmentRequest"
      responses:
        "200":
          description: Create Orders Assignments
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/OrderAssignment"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/orders/{id}/events:
    get:
      operationId: getOrdersByIdEvents
      summary: Get Orders Events by ID
      tags:
        - Orders
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: Get Orders Events by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/OrderEvent"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createOrdersByIdEvents
      summary: Create Orders Events
      tags:
        - Orders
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateOrderEventRequest"
      responses:
        "200":
          description: Create Orders Events
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/OrderEvent"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/orders/{id}/results:
    get:
      operationId: getOrdersByIdResults
      summary: Get Orders Results by ID
      tags:
        - Orders
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: Get Orders Results by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/OrderResult"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createOrdersByIdResults
      summary: Create Orders Results
      tags:
        - Orders
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateOrderResultRequest"
      responses:
        "200":
          description: Create Orders Results
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/OrderResult"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/orders/by-session:
    get:
      operationId: getOrdersBySession
      summary: List Orders By Session
      tags:
        - Orders
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Orders By Session
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Order"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/orders/create-test-orders:
    post:
      operationId: createOrdersCreateTestOrders
      summary: Create Orders Create Test Orders
      tags:
        - Orders
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTestOrdersRequest"
      responses:
        "200":
          description: Create Orders Create Test Orders
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/organizations/bulk-delete:
    post:
      operationId: createOrganizationsBulkDelete
      summary: Create Organizations Bulk Delete
      tags:
        - Organizations
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkDeleteRequest"
      responses:
        "200":
          description: Create Organizations Bulk Delete
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/people/me/verify-driver-license-mock:
    post:
      operationId: createPeopleMeVerifyDriverLicenseMock
      summary: Create People Me Verify Driver License Mock
      tags:
        - People
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/VerifyDriverLicenseMockRequest"
      responses:
        "200":
          description: Create People Me Verify Driver License Mock
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/VerifyDriverLicenseMockResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/{resource}/batch:
    delete:
      operationId: deletePlatformByResourceBatch
      summary: Delete Platform Batch
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: resource
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/action-item-templates:
    get:
      operationId: getPlatformActionItemTemplates
      summary: List Platform Action Item Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Action Item Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ActionItemTemplate"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: replacePlatformActionItemTemplates
      summary: Replace Platform Action Item Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkUpdateActionItemTemplatesRequest"
      responses:
        "200":
          description: Replace Platform Action Item Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/ActionItemTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformActionItemTemplates
      summary: Update Platform Action Item Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateActionItemTemplateRequest"
      responses:
        "200":
          description: Update Platform Action Item Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ActionItemTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/connectors/{connectorName}/files:
    get:
      operationId: getPlatformConnectorsByConnectorNameFiles
      summary: Get Platform Connectors Files by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: connectorName
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Connectors Files by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConnectorFilesResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformConnectorsByConnectorNameFiles
      summary: Create Platform Connectors Files
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: connectorName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ConnectorFileActionRequest"
      responses:
        "200":
          description: Create Platform Connectors Files
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/connectors/{connectorName}/health:
    get:
      operationId: getPlatformConnectorsByConnectorNameHealth
      summary: Get Platform Connectors Health by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: connectorName
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Connectors Health by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConnectorHealthResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/connectors/{connectorName}/sftp-host-keys:
    get:
      operationId: getPlatformConnectorsByConnectorNameSftpHostKeys
      summary: Get Platform Connectors Sftp Host Keys by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: connectorName
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Connectors Sftp Host Keys by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SftpHostKeysData"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/connectors/{connectorName}/sftp-keys:
    get:
      operationId: getPlatformConnectorsByConnectorNameSftpKeys
      summary: Get Platform Connectors Sftp Keys by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: connectorName
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Connectors Sftp Keys by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SftpKeysResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: replacePlatformConnectorsByConnectorNameSftpKeys
      summary: Replace Platform Connectors Sftp Keys
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: connectorName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SftpKeysUpdateRequest"
      responses:
        "200":
          description: Replace Platform Connectors Sftp Keys
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SftpKeysUpdateResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/connectors/{connectorName}/sftp-reachability:
    get:
      operationId: getPlatformConnectorsByConnectorNameSftpReachability
      summary: Get Platform Connectors Sftp Reachability by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: connectorName
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Connectors Sftp Reachability by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SftpReachabilityResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/connectors/{connectorName}/test-sftp-file:
    post:
      operationId: createPlatformConnectorsByConnectorNameTestSftpFile
      summary: Create Platform Connectors Test Sftp File
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: connectorName
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/TestSftpFileRequest"
      responses:
        "200":
          description: Create Platform Connectors Test Sftp File
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/TestSftpFileResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/dashboard-stats:
    get:
      operationId: getPlatformDashboardStats
      summary: List Platform Dashboard Stats
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Dashboard Stats
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/DashboardStats"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/demo-activations:
    post:
      operationId: createPlatformDemoActivations
      summary: Create Platform Demo Activations
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDemoActivationRequest"
      responses:
        "200":
          description: Create Platform Demo Activations
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/CreateDemoActivationResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/demo/add-results:
    post:
      operationId: createPlatformDemoAddResults
      summary: Create Platform Demo Add Results
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Platform Demo Add Results
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/demo/simulate-complete-return:
    post:
      operationId: createPlatformDemoSimulateCompleteReturn
      summary: Create Platform Demo Simulate Complete Return
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Platform Demo Simulate Complete Return
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/demo/simulate-lab-checkin:
    post:
      operationId: createPlatformDemoSimulateLabCheckin
      summary: Create Platform Demo Simulate Lab Checkin
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Platform Demo Simulate Lab Checkin
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/demo/simulate-lab-processing:
    post:
      operationId: createPlatformDemoSimulateLabProcessing
      summary: Create Platform Demo Simulate Lab Processing
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Platform Demo Simulate Lab Processing
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/demo/upload-results:
    get:
      operationId: getPlatformDemoUploadResults
      summary: List Platform Demo Upload Results
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Demo Upload Results
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformDemoUploadResults
      summary: Create Platform Demo Upload Results
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Platform Demo Upload Results
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/device-onboarding-steps:
    get:
      operationId: getPlatformDeviceOnboardingSteps
      summary: List Platform Device Onboarding Steps
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Device Onboarding Steps
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/DeviceActivationStep"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformDeviceOnboardingSteps
      summary: Create Platform Device Onboarding Steps
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateDeviceActivationStepRequest"
      responses:
        "200":
          description: Create Platform Device Onboarding Steps
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/DeviceActivationStep"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: replacePlatformDeviceOnboardingSteps
      summary: Replace Platform Device Onboarding Steps
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateDeviceActivationStepRequest"
      responses:
        "200":
          description: Replace Platform Device Onboarding Steps
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/DeviceActivationStep"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformDeviceOnboardingSteps
      summary: Delete Platform Device Onboarding Steps
      tags:
        - Platform
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/device-templates:
    get:
      operationId: getPlatformDeviceTemplates
      summary: List Platform Device Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Device Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/DeviceTemplate"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformDeviceTemplates
      summary: Create Platform Device Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDeviceRequest"
      responses:
        "200":
          description: Create Platform Device Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/DeviceTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: replacePlatformDeviceTemplates
      summary: Replace Platform Device Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDeviceRequest"
      responses:
        "200":
          description: Replace Platform Device Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/DeviceTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformDeviceTemplates
      summary: Delete Platform Device Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/devices/{deviceId}:
    get:
      operationId: getPlatformDevicesByDeviceId
      summary: Get Platform Devices by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Devices by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Device"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformDevicesByDeviceId
      summary: Update Platform Devices
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDeviceRequest"
      responses:
        "200":
          description: Update Platform Devices
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Device"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformDevicesByDeviceId
      summary: Delete Platform Devices
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/devices/{deviceId}/template:
    post:
      operationId: createPlatformDevicesByDeviceIdTemplate
      summary: Create Platform Devices Template
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Platform Devices Template
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/devices:
    get:
      operationId: getPlatformDevices
      summary: List Platform Devices
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
        - name: organization_id
          in: query
          required: false
          schema:
            type: string
          description: Filter by organization ID
        - name: status
          in: query
          required: false
          schema:
            type: string
          description: Filter by device status
        - name: q
          in: query
          required: false
          schema:
            type: string
          description: Search name, device type, or barcode prefix (ilike)
        - name: anchor_device_id
          in: query
          required: false
          schema:
            type: string
          description: UUID of a device; aligns offset to the page containing it (same filters/sort)
      responses:
        "200":
          description: List Platform Devices
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Device"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformDevices
      summary: Create Platform Devices
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateDeviceRequest"
      responses:
        "200":
          description: Create Platform Devices
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Device"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/educational-articles:
    get:
      operationId: getPlatformEducationalArticles
      summary: List Platform Educational Articles
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Educational Articles
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/EducationalArticle"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformEducationalArticles
      summary: Create Platform Educational Articles
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateArticleRequest"
      responses:
        "200":
          description: Create Platform Educational Articles
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalArticle"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: replacePlatformEducationalArticles
      summary: Replace Platform Educational Articles
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateArticleRequest"
      responses:
        "200":
          description: Replace Platform Educational Articles
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalArticle"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformEducationalArticles
      summary: Delete Platform Educational Articles
      tags:
        - Platform
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/educational-categories:
    get:
      operationId: getPlatformEducationalCategories
      summary: List Platform Educational Categories
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Educational Categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/EducationalCategory"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformEducationalCategories
      summary: Create Platform Educational Categories
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCategoryRequest"
      responses:
        "200":
          description: Create Platform Educational Categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalCategory"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: replacePlatformEducationalCategories
      summary: Replace Platform Educational Categories
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateCategoryRequest"
      responses:
        "200":
          description: Replace Platform Educational Categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalCategory"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformEducationalCategories
      summary: Delete Platform Educational Categories
      tags:
        - Platform
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/educational-videos:
    get:
      operationId: getPlatformEducationalVideos
      summary: List Platform Educational Videos
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Educational Videos
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/EducationalVideo"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformEducationalVideos
      summary: Create Platform Educational Videos
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateVideoRequest"
      responses:
        "200":
          description: Create Platform Educational Videos
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalVideo"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: replacePlatformEducationalVideos
      summary: Replace Platform Educational Videos
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateVideoRequest"
      responses:
        "200":
          description: Replace Platform Educational Videos
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EducationalVideo"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformEducationalVideos
      summary: Delete Platform Educational Videos
      tags:
        - Platform
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/email-templates:
    get:
      operationId: getPlatformEmailTemplates
      summary: List Platform Email Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Email Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/EmailTemplate"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformEmailTemplates
      summary: Create Platform Email Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateEmailTemplateRequest"
      responses:
        "200":
          description: Create Platform Email Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EmailTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: replacePlatformEmailTemplates
      summary: Replace Platform Email Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateEmailTemplateRequest"
      responses:
        "200":
          description: Replace Platform Email Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EmailTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformEmailTemplates
      summary: Delete Platform Email Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/kitting/orders:
    get:
      operationId: getPlatformKittingOrders
      summary: List Platform Kitting Orders
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Kitting Orders
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Order"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/orders/{id}:
    get:
      operationId: getPlatformOrdersById
      summary: Get Platform Orders by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Orders by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Order"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformOrdersById
      summary: Update Platform Orders
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePlatformOrderRequest"
      responses:
        "200":
          description: Update Platform Orders
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Order"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformOrdersById
      summary: Delete Platform Orders
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/orders:
    get:
      operationId: getPlatformOrders
      summary: List Platform Orders
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Orders
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Order"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformOrders
      summary: Create Platform Orders
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateOrderRequest"
      responses:
        "200":
          description: Create Platform Orders
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Order"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/panel-categories/{id}:
    patch:
      operationId: updatePlatformPanelCategoriesById
      summary: Update Platform Panel Categories
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePanelCategoryRequest"
      responses:
        "200":
          description: Update Platform Panel Categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PanelCategory"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformPanelCategoriesById
      summary: Delete Platform Panel Categories
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/panel-categories:
    get:
      operationId: getPlatformPanelCategories
      summary: List Platform Panel Categories
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Panel Categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PanelCategory"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformPanelCategories
      summary: Create Platform Panel Categories
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePanelCategoryRequest"
      responses:
        "200":
          description: Create Platform Panel Categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PanelCategory"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/questionnaire-templates/{id}:
    get:
      operationId: getPlatformQuestionnaireTemplatesById
      summary: Get Platform Questionnaire Templates by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Questionnaire Templates by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/QuestionnaireTemplate"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformQuestionnaireTemplatesById
      summary: Update Platform Questionnaire Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateQuestionnaireTemplateRequest"
      responses:
        "200":
          description: Update Platform Questionnaire Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/QuestionnaireTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformQuestionnaireTemplatesById
      summary: Delete Platform Questionnaire Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/questionnaire-templates:
    get:
      operationId: getPlatformQuestionnaireTemplates
      summary: List Platform Questionnaire Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Questionnaire Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/QuestionnaireTemplate"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformQuestionnaireTemplates
      summary: Create Platform Questionnaire Templates
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateQuestionnaireTemplateRequest"
      responses:
        "200":
          description: Create Platform Questionnaire Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/QuestionnaireTemplate"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/roles/{id}:
    patch:
      operationId: updatePlatformRolesById
      summary: Update Platform Roles
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateRoleRequest"
      responses:
        "200":
          description: Update Platform Roles
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformRole"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformRolesById
      summary: Delete Platform Roles
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/roles:
    get:
      operationId: getPlatformRoles
      summary: List Platform Roles
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Roles
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PlatformRole"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformRoles
      summary: Create Platform Roles
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateRoleRequest"
      responses:
        "200":
          description: Create Platform Roles
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformRole"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/roles/stats:
    get:
      operationId: getPlatformRolesStats
      summary: List Platform Roles Stats
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Roles Stats
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/RoleStats"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/route-usage:
    get:
      operationId: getPlatformRouteUsage
      summary: List Platform Route Usage
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Route Usage
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/routes:
    get:
      operationId: getPlatformRoutes
      summary: List Platform Routes
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Routes
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/scheduled-actions:
    get:
      operationId: getPlatformScheduledActions
      summary: List Platform Scheduled Actions
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Scheduled Actions
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/schema:
    get:
      operationId: getPlatformSchema
      summary: List Platform Schema
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Schema
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/settings:
    get:
      operationId: getPlatformSettings
      summary: List Platform Settings
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Settings
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PlatformSetting"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformSettings
      summary: Create Platform Settings
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSettingRequest"
      responses:
        "200":
          description: Create Platform Settings
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformSetting"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformSettings
      summary: Update Platform Settings
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateSettingRequest"
      responses:
        "200":
          description: Update Platform Settings
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformSetting"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformSettings
      summary: Delete Platform Settings
      tags:
        - Platform
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/test-panels/{id}:
    get:
      operationId: getPlatformTestPanelsById
      summary: Get Platform Test Panels by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Test Panels by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/TestPanel"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformTestPanelsById
      summary: Update Platform Test Panels
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTestPanelRequest"
      responses:
        "200":
          description: Update Platform Test Panels
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/TestPanel"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformTestPanelsById
      summary: Delete Platform Test Panels
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/test-panels/counts:
    get:
      operationId: getPlatformTestPanelsCounts
      summary: List Platform Test Panels Counts
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Test Panels Counts
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/test-panels:
    get:
      operationId: getPlatformTestPanels
      summary: List Platform Test Panels
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Test Panels
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/TestPanel"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformTestPanels
      summary: Create Platform Test Panels
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateTestPanelRequest"
      responses:
        "200":
          description: Create Platform Test Panels
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/TestPanel"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/{id}/action-items/{itemId}:
    patch:
      operationId: updatePlatformUsersByIdActionItemsByItemId
      summary: Update Platform Users Action Items
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
        - name: itemId
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePlatformUserActionItemRequest"
      responses:
        "200":
          description: Update Platform Users Action Items
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PortalActionItem"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/{id}/action-items:
    get:
      operationId: getPlatformUsersByIdActionItems
      summary: Get Platform Users Action Items by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Users Action Items by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformUserActionItemsResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/{id}/assign-role:
    post:
      operationId: createPlatformUsersByIdAssignRole
      summary: Create Platform Users Assign Role
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AssignRoleRequest"
      responses:
        "200":
          description: Create Platform Users Assign Role
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformUser"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/{id}/reset-consent:
    post:
      operationId: createPlatformUsersByIdResetConsent
      summary: Create Platform Users Reset Consent
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Platform Users Reset Consent
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformUser"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/{id}/reset-password:
    post:
      operationId: createPlatformUsersByIdResetPassword
      summary: Create Platform Users Reset Password
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Platform Users Reset Password
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/{id}:
    get:
      operationId: getPlatformUsersById
      summary: Get Platform Users by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Platform Users by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformUser"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformUsersById
      summary: Update Platform Users
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePlatformUserRequest"
      responses:
        "200":
          description: Update Platform Users
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformUser"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformUsersById
      summary: Delete Platform Users
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/check-permissions:
    get:
      operationId: getPlatformUsersCheckPermissions
      summary: List Platform Users Check Permissions
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Platform Users Check Permissions
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/CheckPermissionsResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/invite:
    post:
      operationId: createPlatformUsersInvite
      summary: Create Platform Users Invite
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/InviteUserRequest"
      responses:
        "200":
          description: Create Platform Users Invite
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformUser"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users:
    get:
      operationId: getPlatformUsers
      summary: List Platform Users
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
        - name: role
          in: query
          required: false
          schema:
            type: string
          description: Filter by role
        - name: organization_id
          in: query
          required: false
          schema:
            type: string
          description: Filter by organization ID
        - name: banned
          in: query
          required: false
          schema:
            type: boolean
          description: Filter by banned status
      responses:
        "200":
          description: List Platform Users
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PlatformUser"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformUsers
      summary: Create Platform Users
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePlatformUserRequest"
      responses:
        "200":
          description: Create Platform Users
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformUser"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformUsers
      summary: Update Platform Users
      tags:
        - Platform
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePlatformUserRequest"
      responses:
        "200":
          description: Update Platform Users
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlatformUser"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformUsers
      summary: Delete Platform Users
      tags:
        - Platform
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Deleted successfully
          content:
            application/json:
              schema: *a2
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal-access:
    get:
      operationId: getPortalAccess
      summary: List Portal Access
      tags:
        - Portal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Portal Access
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/action-items:
    get:
      operationId: getPortalActionItems
      summary: List Portal Action Items
      tags:
        - Portal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Portal Action Items
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PortalActionItem"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePortalActionItems
      summary: Update Portal Action Items
      tags:
        - Portal
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePortalActionItemRequest"
      responses:
        "200":
          description: Update Portal Action Items
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PortalActionItem"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/bootstrap:
    get:
      operationId: getPortalBootstrap
      summary: List Portal Bootstrap
      tags:
        - Portal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Portal Bootstrap
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PortalBootstrapResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/consents:
    get:
      operationId: getPortalConsents
      summary: List Portal Consents
      tags:
        - Portal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Portal Consents
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/MemberConsent"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/questionnaire-responses:
    get:
      operationId: getPortalQuestionnaireResponses
      summary: List Portal Questionnaire Responses
      tags:
        - Portal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Portal Questionnaire Responses
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/QuestionnaireResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPortalQuestionnaireResponses
      summary: Create Portal Questionnaire Responses
      tags:
        - Portal
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateQuestionnaireResponseRequest"
      responses:
        "200":
          description: Create Portal Questionnaire Responses
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/QuestionnaireResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/questionnaire-templates:
    get:
      operationId: getPortalQuestionnaireTemplates
      summary: List Portal Questionnaire Templates
      tags:
        - Portal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Portal Questionnaire Templates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/QuestionnaireTemplate"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portals:
    get:
      operationId: getPortals
      summary: List Portals
      tags:
        - Portal
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Portals
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/public/activation-info/{activationUid}:
    get:
      operationId: getPublicActivationInfoByActivationUid
      summary: Get Public Activation Info by ID
      tags:
        - Public
      security:
        - ServiceRoleKey: []
      parameters:
        - name: activationUid
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Public Activation Info by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/KitActivationInfo"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/public/email-check:
    get:
      operationId: getPublicEmailCheck
      summary: List Public Email Check
      tags:
        - Public
      security:
        - ServiceRoleKey: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Public Email Check
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/EmailCheckResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/public/kit-agreements:
    get:
      operationId: getPublicKitAgreements
      summary: List Public Kit Agreements
      tags:
        - Public
      security:
        - ServiceRoleKey: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Public Kit Agreements
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/KitAgreementsResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/public/kit-lookup:
    get:
      operationId: getPublicKitLookup
      summary: List Public Kit Lookup
      tags:
        - Public
      security:
        - ServiceRoleKey: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Public Kit Lookup
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/KitLookupResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/public/kit-register:
    post:
      operationId: createPublicKitRegister
      summary: Create Public Kit Register
      tags:
        - Public
      security:
        - ServiceRoleKey: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/KitRegisterRequest"
      responses:
        "200":
          description: Create Public Kit Register
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/KitRegisterResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/public/panels:
    get:
      operationId: getPublicPanels
      summary: List Public Panels
      tags:
        - Public
      security:
        - ServiceRoleKey: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Public Panels
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Product"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/return-labels/mock/{activationUid}:
    get:
      operationId: getReturnLabelsMockByActivationUid
      summary: Get Return Labels Mock by ID
      tags:
        - DeviceActivations
      parameters:
        - name: activationUid
          in: path
          required: true
          schema:
            type: string
      responses:
        "200":
          description: Get Return Labels Mock by ID
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ReturnLabelInfo"
  /api:
    get:
      operationId: get
      summary: API root redirect
      tags:
        - Public
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: API root redirect
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
  /api/stripe/checkout-session:
    post:
      operationId: createStripeCheckoutSession
      summary: Create Stripe Checkout Session
      tags:
        - Payments
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StripeCheckoutRequest"
      responses:
        "200":
          description: Create Stripe Checkout Session
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/StripeCheckoutResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/stripe/verify-session:
    post:
      operationId: createStripeVerifySession
      summary: Create Stripe Verify Session
      tags:
        - Payments
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/StripeVerifySessionRequest"
      responses:
        "200":
          description: Create Stripe Verify Session
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/StripeVerifySessionResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/stripe/webhook:
    post:
      operationId: createStripeWebhook
      summary: Create Stripe Webhook
      tags:
        - Payments
      security:
        - WebhookSignature: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Stripe Webhook
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/test-email:
    post:
      operationId: createTestEmail
      summary: Create Test Email
      tags:
        - Internal
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SuccessResponse"
      responses:
        "200":
          description: Create Test Email
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/test-panels:
    get:
      operationId: getTestPanels
      summary: List Test Panels
      tags:
        - TestPanels
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          required: false
          schema:
            type: integer
            minimum: 1
            maximum: 500
            default: 50
          description: Maximum number of results to return
        - name: offset
          in: query
          required: false
          schema:
            type: integer
            minimum: 0
            default: 0
          description: Number of results to skip
      responses:
        "200":
          description: List Test Panels
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/TestPanel"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/health:
    get:
      operationId: getHealth
      summary: Health check
      tags:
        - Public
      description: Liveness check for load balancers and monitoring.
      responses:
        "200":
          description: Service is healthy
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/HealthCheck"
  /api/auth/login:
    post:
      operationId: login
      summary: Sign in with email/password
      tags:
        - Auth
      description: Returns access and refresh tokens. Rate limited (10/15min per IP).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LoginRequest"
      responses:
        "200":
          description: Login successful
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/AuthTokens"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/auth/signup:
    post:
      operationId: signup
      summary: Create a new account
      tags:
        - Auth
      description: |-
        Sign up with email/password. Returns tokens immediately if email confirmation
        is not required, or `confirmEmail: true` if the user must verify their email first.
        Rate limited (10/15min per IP).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/SignupRequest"
      responses:
        "200":
          description: Signup successful
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    oneOf:
                      - $ref: "#/components/schemas/SignupResponseImmediate"
                      - $ref: "#/components/schemas/SignupResponseConfirm"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/auth/refresh:
    post:
      operationId: refreshToken
      summary: Refresh access token
      tags:
        - Auth
      description: Exchange a refresh token for new access and refresh tokens.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/RefreshRequest"
      responses:
        "200":
          description: Token refreshed
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/AuthTokens"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/auth/logout:
    post:
      operationId: logout
      summary: Log out
      tags:
        - Auth
      description: Invalidates the session. Frontend must clear stored tokens.
      responses:
        "200":
          description: Logged out
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        enum:
                          - true
  /api/auth/sessions/revoke-others:
    post:
      operationId: revokeOtherSessions
      summary: Revoke all other sessions
      tags:
        - Auth
      description: Invalidates all refresh tokens for the authenticated user except the one tied to the current access token.
        Called automatically on login to enforce single-session semantics.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
              additionalProperties: false
      responses:
        "200":
          description: Other sessions revoked
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      email:
                        type: string
                        description: The user's email address
                    required:
                      - email
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/auth/me:
    get:
      operationId: getCurrentUser
      summary: Get current user
      tags:
        - Auth
      description: Returns the authenticated user's profile.
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Current user
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/UserSummary"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updateCurrentUser
      summary: Update current user
      tags:
        - Auth
      description: Update user metadata (currently supports full_name).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - full_name
              properties:
                full_name:
                  type: string
                  minLength: 1
                  maxLength: 255
      responses:
        "200":
          description: Updated user
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/UserSummary"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/auth/oauth:
    get:
      operationId: initiateOAuth
      summary: Initiate OAuth flow
      tags:
        - Auth
      description: |-
        Initiate Google OAuth. Browser clients are redirected; API clients
        (Accept: application/json) receive `{ data: { url } }`.
      parameters:
        - name: provider
          in: query
          schema:
            type: string
            enum:
              - google
          required: true
        - name: redirect_to
          in: query
          schema:
            type: string
      responses:
        "200":
          description: OAuth URL (API clients)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      url:
                        type: string
                        format: uri
        "302":
          description: Redirect to OAuth provider (browser clients)
  /api/auth/otp:
    post:
      operationId: requestOtp
      summary: Request magic link (OTP)
      tags:
        - Auth
      description: |-
        Triggers a passwordless sign-in email. Always returns 200 to prevent email enumeration.
        Rate limited (10/15min per IP).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/OtpRequest"
      responses:
        "200":
          description: OTP sent (or generic message)
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      message:
                        type: string
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/auth/send-email:
    post:
      operationId: supabaseAuthSendEmail
      summary: Supabase auth send-email hook
      tags:
        - Auth
      description: |-
        Webhook endpoint for the Supabase Auth "Send Email" hook.
        Receives auth email events and sends branded emails via Mailgun.
        Signature verified via standardwebhooks (SEND_EMAIL_HOOK_SECRET).
      security:
        - WebhookSignature: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - user
                - email_data
              properties:
                user:
                  type: object
                  properties:
                    email:
                      type: string
                      format: email
                    email_new:
                      type: string
                      format: email
                      description: New email address (secure email_change mode only)
                email_data:
                  type: object
                  required:
                    - email_action_type
                  properties:
                    token:
                      type: string
                    token_hash:
                      type: string
                    token_new:
                      type: string
                    token_hash_new:
                      type: string
                      description: Token for current email address (email_change secure mode)
                    redirect_to:
                      type: string
                      format: uri
                    email_action_type:
                      type: string
                      enum:
                        - signup
                        - recovery
                        - magiclink
                        - invite
                        - email_change
                    site_url:
                      type: string
                      format: uri
      responses:
        "200":
          description: Email sent successfully
          content:
            application/json:
              schema:
                type: object
                properties: {}
                additionalProperties: false
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "503":
          description: Service unavailable
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/me:
    get:
      operationId: getPortalProfile
      summary: Get portal profile
      tags:
        - Portal
      description: Returns the current user's portal profile (person record, org, flags).
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Portal profile
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PortalProfile"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/biomarkers:
    get:
      operationId: getPortalBiomarkers
      summary: Get biomarkers
      tags:
        - Portal
      description: Returns biomarker results for the current user. Use `?attention=true` for abnormal only.
      security:
        - BearerAuth: []
      parameters:
        - name: attention
          in: query
          schema:
            type: string
            enum:
              - "true"
              - "false"
          description: If true, return only abnormal biomarkers
      responses:
        "200":
          description: Biomarker list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Biomarker"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/health-summary:
    get:
      operationId: getPortalHealthSummary
      summary: Get health summary
      tags:
        - Portal
      description: Aggregated biomarker stats — health score, optimal/attention counts, categories.
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Health summary
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/HealthSummary"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/partnerships:
    get:
      operationId: getPortalPartnerships
      summary: List partnerships
      tags:
        - Portal
      description: List active partnerships for the current user with redemption status.
      security:
        - BearerAuth: []
      parameters:
        - name: category_id
          in: query
          schema:
            type: string
            format: uuid
        - name: search
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: Partnership list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PartnershipPortal"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/partnerships/categories:
    get:
      operationId: getPortalPartnershipCategories
      summary: List partnership categories
      tags:
        - Portal
      description: List active partnership categories with active partnership counts.
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Partnership categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PartnershipCategoryWithCount"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/partnerships/{id}/redeem:
    post:
      operationId: redeemPortalPartnership
      summary: Redeem partnership
      tags:
        - Portal
      description: Redeem a partnership perk for the current user.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "201":
          description: Partnership redeemed
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PartnershipRedeemResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "409":
          description: Conflict
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/download-result/{orderPanelId}:
    get:
      operationId: getResultDownloadUrl
      summary: Get result download URL
      tags:
        - Portal
      description: |-
        Returns a signed URL for downloading a lab result PDF.
        Access: order owner or platform employee.
      security:
        - BearerAuth: []
      parameters:
        - name: orderPanelId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Signed download URL
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/DownloadUrl"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/search:
    get:
      operationId: searchAll
      summary: Unified search
      tags:
        - Search
      description: Search across people, orders, and products. Returns matching records by category.
      security:
        - BearerAuth: []
      parameters:
        - name: q
          in: query
          schema:
            type: string
            minLength: 2
            maxLength: 200
          description: Search term
          required: true
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
          description: "Results per category (default: 20)"
        - name: type
          in: query
          schema:
            type: string
            enum:
              - people
              - orders
              - products
          description: Filter by type (omit for all)
      responses:
        "200":
          description: Search results
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    required:
                      - people
                      - orders
                      - products
                    properties:
                      people:
                        type: array
                        items:
                          $ref: "#/components/schemas/Person"
                      orders:
                        type: array
                        items:
                          $ref: "#/components/schemas/Order"
                      products:
                        type: array
                        items:
                          $ref: "#/components/schemas/Product"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/orders:
    get:
      operationId: listOrders
      summary: List orders
      tags:
        - Orders
      description: List orders with optional filtering and pagination.
      security:
        - BearerAuth: []
      parameters:
        - name: organization_id
          in: query
          schema:
            type: string
            format: uuid
        - name: person_id
          in: query
          schema:
            type: string
            format: uuid
        - name: status
          in: query
          schema:
            type: string
        - name: include_relations
          in: query
          schema:
            type: string
            enum:
              - "true"
              - "false"
          description: Include related records (person, order_items, device_activations)
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: Order list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/OrderWithRelations"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createOrder
      summary: Create an order
      tags:
        - Orders
      description: Create a new order for the authenticated user's person record.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateOrderRequest"
      responses:
        "201":
          description: Order created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      order:
                        $ref: "#/components/schemas/Order"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/orders/{id}:
    get:
      operationId: getOrder
      summary: Get order by ID
      tags:
        - Orders
      description: Returns a single order by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Order details
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Order"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updateOrder
      summary: Update an order
      tags:
        - Orders
      description: Update an order by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateOrderRequest"
      responses:
        "200":
          description: Order updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Order"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteOrder
      summary: Delete an order
      tags:
        - Orders
      description: Delete an order by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Order deleted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/results:
    get:
      operationId: listResults
      summary: List results
      tags:
        - Results
      description: |-
        Returns lab result panels for the current user. Includes expected (pending)
        results from activated orders by default.
        Each row includes `panel_status` (canonical) and duplicate `status` with the same value
        so portal clients can filter on either field (HO-920).
      security:
        - BearerAuth: []
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum:
              - pending
              - sample_collected
              - received_at_lab
              - processing
              - completed
              - reviewed
              - cancelled
          description: Filter by panel status
        - name: completedOnly
          in: query
          schema:
            type: string
            enum:
              - "true"
              - "false"
          description: Return only completed/reviewed panels
        - name: includeExpected
          in: query
          schema:
            type: string
            enum:
              - "true"
              - "false"
          description: Include expected (pending) results from activated orders (default true)
        - name: person_id
          in: query
          schema:
            type: string
            format: uuid
          description: Filter by person ID
      responses:
        "200":
          description: Results list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/OrderPanel"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/results/{orderPanelId}:
    get:
      operationId: getResult
      summary: Get result by order panel ID
      tags:
        - Results
      description: Returns a single order panel with full test result details.
      security:
        - BearerAuth: []
      parameters:
        - name: orderPanelId
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Order panel with results
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/OrderPanel"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/public/platform-status:
    get:
      operationId: getPlatformStatus
      summary: Get platform status
      tags:
        - Public
      description: Returns maintenance mode, visual overlay toggle, and company name.
      responses:
        "200":
          description: Platform status
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PlatformStatus"
        "503":
          description: Service unavailable
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/changelog:
    get:
      operationId: getChangelog
      summary: Platform product changelog
      tags:
        - Platform
      description: |-
        Returns release notes for the platform changelog UI.
        Primary source is the `changelog_entries` table (filled by CI after deploy).
        Falls back to GitHub Releases for this repo, then a static seed.
        Response is raw JSON (not wrapped in `{ data }`).
        Requires a platform employee session.
      security:
        - BearerAuth: []
      parameters:
        - name: page
          in: query
          schema:
            type: integer
            minimum: 1
            default: 1
          description: Page number (DB-backed only)
        - name: per_page
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 100
            default: 20
          description: Page size (DB-backed only)
      responses:
        "200":
          description: Changelog releases
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ChangelogResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/public/org-branding:
    get:
      operationId: getOrgBranding
      summary: Get organization branding
      tags:
        - Public
      description: |-
        Returns branding (logo, colors, name) for an organization.
        Without `uid`, returns default platform branding.
      parameters:
        - name: uid
          in: query
          schema:
            type: string
            format: uuid
          description: Organization UUID
      responses:
        "200":
          description: Organization branding
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrgBranding"
        "400":
          description: Invalid UUID format (returns default branding)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrgBranding"
        "404":
          description: Organization not found (returns default branding)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/OrgBranding"
  /api/public/orders:
    post:
      operationId: createPublicOrder
      summary: Create a public order
      tags:
        - Public
      description: |-
        Create an order from the public storefront. No authentication required.
        Creates or links to existing customer record by email.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PublicOrderRequest"
      responses:
        "201":
          description: Order created
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/PublicOrderResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/roles:
    get:
      operationId: listRoles
      summary: List roles
      tags:
        - Public
      description: Returns all roles. No auth required. Cached for 1 hour.
      responses:
        "200":
          description: Roles list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Role"
  /api/feedback:
    get:
      operationId: getFeedbackConfig
      summary: Get feedback config
      tags:
        - Feedback
      description: Returns whether feedback integration is enabled.
      responses:
        "200":
          description: Feedback config
          content:
            application/json:
              schema:
                type: object
                properties:
                  service:
                    type: string
                  status:
                    type: string
                  github_enabled:
                    type: boolean
                  repo:
                    type:
                      - string
                      - "null"
    post:
      operationId: submitFeedback
      summary: Submit feedback
      tags:
        - Feedback
      description: Creates a GitHub issue with the feedback. Rate limited (5/min per IP).
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - title
                - description
                - context
              properties:
                title:
                  type: string
                  maxLength: 500
                description:
                  type: string
                  maxLength: 10000
                context:
                  type: object
                  required:
                    - url
                    - userAgent
                    - viewport
                    - consoleLogs
                    - timestamp
                  properties:
                    url:
                      type: string
                    userAgent:
                      type: string
                    viewport:
                      type: object
                      properties:
                        width:
                          type: integer
                        height:
                          type: integer
                    selectedText:
                      type: string
                    htmlSnippet:
                      type: string
                    cssSelector:
                      type: string
                    elementDescription:
                      type: string
                    consoleLogs:
                      type: array
                      items:
                        type: string
                    lastError:
                      type: string
                    timestamp:
                      type: string
                screenshotDataUrl:
                  type:
                    - string
                    - "null"
      responses:
        "200":
          description: Feedback submitted
          content:
            application/json:
              schema:
                type: object
                properties:
                  success:
                    type: boolean
                  id:
                    type: string
                  html_url:
                    type: string
                    format: uri
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/consent/check:
    get:
      operationId: checkConsent
      summary: Check consent status
      tags:
        - Consent
      description: Returns the current user's consent acceptance status.
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Consent status
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConsentStatus"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/consent/login-terms:
    post:
      operationId: acceptLoginTerms
      summary: Accept Terms and Privacy at login
      tags:
        - Consent
      description: Records ToS + Privacy in member_consents and sets people.login_terms_* (HO-591). Idempotent if already accepted.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/LoginTermsAcceptRequest"
      responses:
        "200":
          description: Login terms recorded
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/LoginTermsAcceptResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/consent/accept:
    post:
      operationId: acceptConsent
      summary: Accept consent
      tags:
        - Consent
      description: |-
        Accept consent for the current user. Optionally verifies a DocuSign envelope
        if the consent flow requires e-signature.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ConsentAcceptRequest"
      responses:
        "200":
          description: Consent accepted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConsentAcceptResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "409":
          description: Conflict
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/consent/decline:
    post:
      operationId: declineConsent
      summary: Log consent declined
      tags:
        - Consent
      description: Log that the user declined or chose "not now" on the consent step. Request metadata (IP, user-agent,
        referer, datetime) is logged for audit.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ConsentDeclineRequest"
      responses:
        "200":
          description: Decline recorded
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ConsentDeclineResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/me/profile-status:
    get:
      operationId: getProfileStatus
      summary: Get profile status
      tags:
        - People
      description: Returns whether the current user's profile needs updating.
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Profile status
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/ProfileStatus"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/people/me:
    get:
      operationId: getMyPerson
      summary: Get current user's person record
      tags:
        - People
      description: |-
        Returns the person record for the authenticated user.
        Optionally checks organization membership when organization_id is provided.
      security:
        - BearerAuth: []
      parameters:
        - name: organization_id
          in: query
          schema:
            type: string
            format: uuid
          description: Check membership in this organization
      responses:
        "200":
          description: Person record
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PersonMe"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updateMyPerson
      summary: Update current user's person record
      tags:
        - People
      description: Update the authenticated user's person profile.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePersonRequest"
      responses:
        "200":
          description: Person updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Person"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/device-activations:
    get:
      operationId: listDeviceActivations
      summary: List device activations
      tags:
        - Device Activations
      description: List device activations with optional status and organization filters. Returns activations with their steps
        included.
      security:
        - BearerAuth: []
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum:
              - pending
              - in_progress
              - activated
              - cancelled
        - name: organization_id
          in: query
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: List of device activations
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/DeviceActivation"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createDeviceActivation
      summary: Create a device activation
      tags:
        - Device Activations
      description: Create a device activation by linking an order and device.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - orderId
                - deviceId
              properties:
                orderId:
                  type: string
                  minLength: 1
                deviceId:
                  type: string
                  minLength: 1
                activationUid:
                  type: string
                  minLength: 1
                  maxLength: 255
      responses:
        "200":
          description: Device activation created
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        enum:
                          - true
                      activation:
                        $ref: "#/components/schemas/DeviceActivation"
                      alreadyExists:
                        type: boolean
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/device-activations/confirm:
    post:
      operationId: confirmDeviceActivation
      summary: Confirm device activation
      tags:
        - Device Activations
      description: Mark a device activation as confirmed. Public endpoint (no auth), rate-limited per IP.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - activationUid
              properties:
                activationUid:
                  type: string
                  minLength: 1
                  maxLength: 255
      responses:
        "200":
          description: Activation confirmed
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/DeviceActivationConfirmResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/device-activations/{activationUid}/steps:
    get:
      operationId: getActivationSteps
      summary: Get activation steps
      tags:
        - Device Activations
      description: Retrieve activation record with all steps. Creates the activation record if it does not exist. Public
        endpoint (no auth), rate-limited per IP.
      parameters:
        - name: activationUid
          in: path
          required: true
          schema:
            type: string
          description: Unique activation identifier
      responses:
        "200":
          description: Activation with steps
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        enum:
                          - true
                      activation:
                        $ref: "#/components/schemas/DeviceActivation"
                      branding:
                        type:
                          - object
                          - "null"
                        properties:
                          organization_id:
                            type: string
                            format: uuid
                          organization_name:
                            type: string
                          logo_url:
                            type:
                              - string
                              - "null"
                            format: uri
                          primary_color:
                            type:
                              - string
                              - "null"
                          accent_color:
                            type:
                              - string
                              - "null"
                          source_url:
                            type:
                              - string
                              - "null"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/device-activations/{activationUid}/steps/{stepId}:
    patch:
      operationId: updateActivationStep
      summary: Update activation step
      tags:
        - Device Activations
      description: Update the status or notes of an activation step. Public endpoint (no auth), rate-limited per IP.
      parameters:
        - name: activationUid
          in: path
          required: true
          schema:
            type: string
          description: Unique activation identifier
        - name: stepId
          in: path
          required: true
          schema:
            type: string
          description: Step identifier
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateDeviceActivationStepRequest"
      responses:
        "200":
          description: Step updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        enum:
                          - true
                      step:
                        $ref: "#/components/schemas/DeviceActivationStep"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/device-activations/{activationUid}/return-label:
    get:
      operationId: getActivationReturnLabel
      summary: Get return shipping label
      tags:
        - Device Activations
      description: Generate or retrieve a return shipping label PDF for an activated device. Public endpoint (no auth),
        rate-limited per IP.
      parameters:
        - name: activationUid
          in: path
          required: true
          schema:
            type: string
          description: Unique activation identifier
      responses:
        "200":
          description: PDF return label
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        "404":
          description: Activation not found or no return label available
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "500":
          description: Internal server error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/people:
    get:
      operationId: listPeople
      summary: List people
      tags:
        - People
      description: List people with optional filtering and pagination.
      security:
        - BearerAuth: []
      parameters:
        - name: organization_id
          in: query
          schema:
            type: string
            format: uuid
        - name: email
          in: query
          schema:
            type: string
        - name: state
          in: query
          schema:
            type: string
        - name: city
          in: query
          schema:
            type: string
        - name: role
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: People list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Person"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPerson
      summary: Create a person
      tags:
        - People
      description: Create a new person record.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreatePersonRequest"
      responses:
        "201":
          description: Person created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      person:
                        $ref: "#/components/schemas/Person"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/people/{id}:
    get:
      operationId: getPerson
      summary: Get person by ID
      tags:
        - People
      description: Returns a single person by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Person details
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Person"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePerson
      summary: Update a person
      tags:
        - People
      description: Update a person record by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdatePersonRequest"
      responses:
        "200":
          description: Person updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Person"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePerson
      summary: Delete a person
      tags:
        - People
      description: Delete a person record by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Person deleted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/address/validate:
    post:
      operationId: validateAddress
      summary: Validate and normalize a postal address
      tags:
        - Address
      description: Calls Google Address Validation API. Requires bearer auth. Use the returned `responseId` as
        `previousResponseId` for follow-up validation when Google requires it.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/AddressValidationRequest"
      responses:
        "200":
          description: Normalized address fields and verdict
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/AddressValidationResult"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "503":
          description: Service unavailable
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/places/autocomplete:
    post:
      operationId: placesAutocomplete
      summary: Places Autocomplete (proxied)
      tags:
        - Places
      description: Server-proxied Google Places Autocomplete (New). Send a stable `sessionToken` (UUID) per user session for
        billing. Do not expose the Maps API key in the browser.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PlacesAutocompleteRequest"
      responses:
        "200":
          description: Autocomplete suggestions
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PlacesAutocompleteResult"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "503":
          description: Service unavailable
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/places/usps-nearby:
    post:
      operationId: placesUspsNearby
      summary: Find nearby USPS post offices
      tags:
        - Places
      description: Server-proxied Google Places Text Search (New) for USPS branches near a given US ZIP. Used by the courier
        pickup drop-off picker.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UspsNearbyRequest"
      responses:
        "200":
          description: Nearby USPS results
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/UspsNearbyResult"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "503":
          description: Service unavailable
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "504":
          description: Gateway timeout (upstream timed out)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/places/map-center:
    post:
      operationId: placesMapCenter
      summary: Geocode text address for map center
      tags:
        - Places
      description: Server-proxied Google Places Text Search (New) returning lat/lng for the best match. Used by the courier
        pickup map rail (Google Maps embed).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/MapCenterRequest"
      responses:
        "200":
          description: Map center coordinates
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/MapCenterResult"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "503":
          description: Service unavailable
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "504":
          description: Gateway timeout (upstream timed out)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/products:
    get:
      operationId: listProducts
      summary: List products
      tags:
        - Products
      description: List products with optional filtering and pagination.
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: Products list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Product"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createProduct
      summary: Create a product
      tags:
        - Products
      description: Create a new product.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateProductRequest"
      responses:
        "201":
          description: Product created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      product:
                        $ref: "#/components/schemas/Product"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/products/{id}:
    get:
      operationId: getProduct
      summary: Get product by ID
      tags:
        - Products
      description: Returns a single product by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Product details
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Product"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updateProduct
      summary: Update a product
      tags:
        - Products
      description: Update a product by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateProductRequest"
      responses:
        "200":
          description: Product updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Product"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteProduct
      summary: Delete a product
      tags:
        - Products
      description: Delete a product by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Product deleted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/organizations:
    get:
      operationId: listOrganizations
      summary: List organizations
      tags:
        - Organizations
      description: List organizations with optional filtering and pagination.
      security:
        - BearerAuth: []
      parameters:
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: Organizations list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Organization"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createOrganization
      summary: Create an organization
      tags:
        - Organizations
      description: Create a new organization.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/CreateOrganizationRequest"
      responses:
        "201":
          description: Organization created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      organization:
                        $ref: "#/components/schemas/Organization"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/organizations/{id}:
    get:
      operationId: getOrganization
      summary: Get organization by ID
      tags:
        - Organizations
      description: Returns a single organization by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Organization details
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Organization"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updateOrganization
      summary: Update an organization
      tags:
        - Organizations
      description: Update an organization by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateOrganizationRequest"
      responses:
        "200":
          description: Organization updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Organization"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteOrganization
      summary: Delete an organization
      tags:
        - Organizations
      description: Delete an organization by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      responses:
        "200":
          description: Organization deleted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/order-items/{id}:
    patch:
      operationId: updateOrderItem
      summary: Update an order item
      tags:
        - Orders
      description: Update an order item by UUID.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/UpdateOrderItemRequest"
      responses:
        "200":
          description: Order item updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/OrderItem"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/order-items/bulk:
    patch:
      operationId: bulkUpdateOrderItems
      summary: Bulk update order items
      tags:
        - Orders
      description: Update multiple order items in a single request.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/BulkUpdateOrderItemsRequest"
      responses:
        "200":
          description: Order items updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/OrderItem"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/uploads:
    post:
      operationId: uploadFile
      summary: Upload file
      tags:
        - Uploads
      description: Upload a file to Supabase Storage. Max 50MB. Rate limited (50/hour per user). Bucket `assets` is
        platform-employee only and accepts images (image/*) or PDF (application/pdf).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: File to upload (max 50MB)
                bucket:
                  type: string
                  default: uploads
                  enum:
                    - uploads
                    - documents
                    - images
                    - assets
                  description: Supabase storage bucket name
                path:
                  type: string
                  description: Optional storage path (auto-generated if omitted)
      responses:
        "200":
          description: File uploaded
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      url:
                        type: string
                        format: uri
                        description: Public URL to access the file
                      path:
                        type: string
                        description: Storage path within bucket
                      size:
                        type: integer
                        description: File size in bytes
                      mimeType:
                        type: string
                        description: MIME type of uploaded file
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "413":
          description: Payload too large
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deleteFile
      summary: Delete file
      tags:
        - Uploads
      description: Delete a file from Supabase Storage. Only delete files whose path is under your user prefix. Use query
        `bucket` (default `uploads`); `assets` requires platform employee.
      security:
        - BearerAuth: []
      parameters:
        - name: path
          in: query
          schema:
            type: string
          description: Storage path to delete
          required: true
        - name: bucket
          in: query
          schema:
            type: string
            enum:
              - uploads
              - documents
              - images
              - assets
          description: Storage bucket (default uploads)
      responses:
        "200":
          description: File deleted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                        enum:
                          - true
                      path:
                        type: string
                        description: Path of deleted file
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/partnership-categories:
    get:
      operationId: listPartnershipCategories
      summary: List partnership categories
      tags:
        - Platform
      description: Admin list of partnership categories.
      security:
        - BearerAuth: []
      parameters:
        - name: is_active
          in: query
          schema:
            type: string
            enum:
              - "true"
              - "false"
        - name: search
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: Partnership categories
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/PartnershipCategory"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPartnershipCategory
      summary: Create partnership category
      tags:
        - Platform
      description: Create a new partnership category.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PartnershipCategoryCreateRequest"
      responses:
        "201":
          description: Partnership category created
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PartnershipCategory"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: updatePartnershipCategory
      summary: Update partnership category
      tags:
        - Platform
      description: Update an existing partnership category.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PartnershipCategoryUpdateRequest"
      responses:
        "200":
          description: Partnership category updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PartnershipCategory"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePartnershipCategory
      summary: Delete partnership category
      tags:
        - Platform
      description: Delete a partnership category by id.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeleteByIdRequest"
      responses:
        "200":
          description: Partnership category deleted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/partnerships:
    get:
      operationId: listPartnerships
      summary: List partnerships
      tags:
        - Platform
      description: Admin list of partnerships.
      security:
        - BearerAuth: []
      parameters:
        - name: category_id
          in: query
          schema:
            type: string
            format: uuid
        - name: is_active
          in: query
          schema:
            type: string
            enum:
              - "true"
              - "false"
        - name: search
          in: query
          schema:
            type: string
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: Partnerships
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/Partnership"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPartnership
      summary: Create partnership
      tags:
        - Platform
      description: Create a new partnership.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PartnershipCreateRequest"
      responses:
        "201":
          description: Partnership created
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Partnership"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    put:
      operationId: updatePartnership
      summary: Update partnership
      tags:
        - Platform
      description: Update an existing partnership.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/PartnershipUpdateRequest"
      responses:
        "200":
          description: Partnership updated
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/Partnership"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePartnership
      summary: Delete partnership
      tags:
        - Platform
      description: Delete a partnership by id.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/DeleteByIdRequest"
      responses:
        "200":
          description: Partnership deleted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/SuccessResponse"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/partnerships/{id}/redemptions:
    get:
      operationId: getPartnershipRedemptions
      summary: Get partnership redemptions
      tags:
        - Platform
      description: Return redemption analytics for a partnership.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
        - name: limit
          in: query
          schema:
            type: integer
            minimum: 1
            maximum: 500
        - name: offset
          in: query
          schema:
            type: integer
            minimum: 0
      responses:
        "200":
          description: Redemptions
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/PartnershipRedemptionsResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/impersonate/{userId}:
    post:
      operationId: impersonateUser
      summary: Impersonate user
      tags:
        - Platform
      description: Create an authenticated session as another user for support/debugging. Only platform_employee role can call
        this endpoint. Cannot impersonate other platform employees. All impersonation sessions are audit logged with
        both identities. Stricter rate limiting applied.
      security:
        - BearerAuth: []
      parameters:
        - name: userId
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Target user ID to impersonate
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ImpersonateRequest"
      responses:
        "200":
          description: Impersonation session created
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/AuthTokens"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "429":
          description: Rate limited
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/admin/demo/reset-kits:
    post:
      operationId: createAdminDemoResetKits
      summary: Reset demo kits
      tags:
        - Admin
      description: Deletes device_activations and sets order_items.status to delivered for given activation_uids. Demo only
        (404 in production).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - activation_uids
              properties:
                activation_uids:
                  type: array
                  items:
                    type: string
                    minLength: 10
                  minItems: 1
                  maxItems: 50
      responses:
        "200":
          description: Demo kits reset
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      success:
                        type: boolean
                      reset_count:
                        type: integer
                      activation_uids:
                        type: array
                        items:
                          type: string
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/dashboard:
    get:
      operationId: getPlatformDashboard
      summary: Platform dashboard
      tags:
        - Platform
      description: "Aggregate stats: totalOrders, totalRevenue, pendingResults, totalUsers, recentOrders, revenueByMonth."
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Dashboard data
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      totalOrders:
                        type: integer
                      totalRevenue:
                        type: number
                      pendingResults:
                        type: integer
                      totalUsers:
                        type: integer
                      recentOrders:
                        type: array
                        items:
                          type: object
                          properties:
                            id:
                              type: string
                              format: uuid
                            order_number:
                              type: string
                            status:
                              type: string
                            amount_cents:
                              type: integer
                            created_at:
                              type: string
                              format: date-time
                            person_id:
                              type: string
                              format: uuid
                      revenueByMonth:
                        type: object
                        additionalProperties:
                          type: number
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/users/{id}/consents:
    get:
      operationId: getPlatformUserConsents
      summary: List consent records for a user
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Auth user ID
      responses:
        "200":
          description: Consent audit trail
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/MemberConsent"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/educational/videos:
    get:
      operationId: getPortalEducationalVideos
      summary: List educational videos for the current user
      tags:
        - Portal
      security:
        - BearerAuth: []
      responses:
        "200":
          description: Educational videos list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      properties:
                        id:
                          type: string
                          format: uuid
                        title:
                          type: string
                        description:
                          type: string
                          nullable: true
                        video_url:
                          type: string
                          format: uri
                        thumbnail_url:
                          type: string
                          format: uri
                          nullable: true
                        duration_seconds:
                          type: integer
                          nullable: true
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/courier-pickup/quote:
    post:
      operationId: createCourierPickupQuote
      summary: Get courier pickup quote
      tags:
        - Portal
        - Courier
      description: Get an Uber Direct delivery quote for blood sample return to USPS.
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - activationId
                - dropoffAddress
              properties:
                activationId:
                  type: string
                  format: uuid
                dropoffAddress:
                  type: object
                  required:
                    - line1
                    - city
                    - state
                    - zip
                  properties:
                    line1:
                      type: string
                    line2:
                      type: string
                    city:
                      type: string
                    state:
                      type: string
                    zip:
                      type: string
                    name:
                      type: string
      responses:
        "200":
          description: Courier pickup quote
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/CourierPickupQuote"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/courier-pickup/{id}:
    get:
      operationId: getCourierPickupStatus
      summary: Get courier pickup status
      tags:
        - Portal
        - Courier
      description: Returns current status of a courier pickup request.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Courier pickup request ID
      responses:
        "200":
          description: Courier pickup status
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/CourierPickupStatus"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/courier-pickup/{id}/confirm:
    post:
      operationId: confirmCourierPickup
      summary: Confirm courier pickup
      tags:
        - Portal
        - Courier
      description: Confirms a quoted pickup — creates the Uber Direct delivery.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Courier pickup request ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                pickupWindowStart:
                  type: string
                  format: date-time
                  nullable: true
                pickupWindowEnd:
                  type: string
                  format: date-time
                  nullable: true
      responses:
        "200":
          description: Confirmed pickup
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/CourierPickupConfirm"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/portal/courier-pickup/{id}/cancel:
    post:
      operationId: cancelCourierPickup
      summary: Cancel courier pickup
      tags:
        - Portal
        - Courier
      description: Cancels a courier pickup request via Uber Direct.
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Courier pickup request ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties: {}
      responses:
        "200":
          description: Cancelled pickup
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    $ref: "#/components/schemas/CourierPickupCancel"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/appointments:
    get:
      operationId: listPlatformAppointments
      summary: List platform appointments
      tags:
        - Platform
      description: Returns all appointments ordered by scheduled_at desc. Filterable by status and full-text search (q).
      security:
        - BearerAuth: []
      parameters:
        - name: status
          in: query
          schema:
            type: string
            enum:
              - All
              - Scheduled
              - Confirmed
              - Completed
              - No-show
              - Cancelled
          description: Filter by status (omit or "All" for no filter)
        - name: q
          in: query
          schema:
            type: string
          description: Search patient name, email, or appointment number
      responses:
        "200":
          description: Appointments list
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      type: object
                      required:
                        - id
                        - appointment_number
                        - patient_name
                        - patient_email
                        - appointment_type
                        - status
                        - scheduled_at
                        - location
                        - provider
                        - created_at
                        - updated_at
                      properties:
                        id:
                          type: string
                          format: uuid
                        appointment_number:
                          type: string
                          example: AP-1001
                        patient_name:
                          type: string
                        patient_email:
                          type: string
                          format: email
                        appointment_type:
                          type: string
                        status:
                          type: string
                          enum:
                            - Scheduled
                            - Confirmed
                            - Completed
                            - No-show
                            - Cancelled
                        scheduled_at:
                          type: string
                          format: date-time
                        location:
                          type: string
                        provider:
                          type: string
                        notes:
                          type: string
                          nullable: true
                        created_at:
                          type: string
                          format: date-time
                        updated_at:
                          type: string
                          format: date-time
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    post:
      operationId: createPlatformAppointment
      summary: Create appointment
      tags:
        - Platform
      description: Creates a new appointment. appointment_number is auto-generated (AP-NNNN).
      security:
        - BearerAuth: []
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - patient_name
                - patient_email
                - scheduled_at
              properties:
                patient_name:
                  type: string
                  minLength: 1
                patient_email:
                  type: string
                  format: email
                appointment_type:
                  type: string
                  default: Blood Draw
                status:
                  type: string
                  enum:
                    - Scheduled
                    - Confirmed
                    - Completed
                    - No-show
                    - Cancelled
                  default: Scheduled
                scheduled_at:
                  type: string
                  format: date-time
                location:
                  type: string
                provider:
                  type: string
                notes:
                  type: string
                  nullable: true
      responses:
        "201":
          description: Appointment created
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      appointment_number:
                        type: string
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/appointments/{id}:
    get:
      operationId: getPlatformAppointment
      summary: Get appointment by ID
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Appointment ID
      responses:
        "200":
          description: Appointment
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      appointment_number:
                        type: string
                      patient_name:
                        type: string
                      patient_email:
                        type: string
                        format: email
                      appointment_type:
                        type: string
                      status:
                        type: string
                        enum:
                          - Scheduled
                          - Confirmed
                          - Completed
                          - No-show
                          - Cancelled
                      scheduled_at:
                        type: string
                        format: date-time
                      location:
                        type: string
                      provider:
                        type: string
                      notes:
                        type: string
                        nullable: true
                      created_at:
                        type: string
                        format: date-time
                      updated_at:
                        type: string
                        format: date-time
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    patch:
      operationId: updatePlatformAppointment
      summary: Partial-update appointment
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Appointment ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                patient_name:
                  type: string
                  minLength: 1
                  maxLength: 255
                patient_email:
                  type: string
                  format: email
                  maxLength: 255
                appointment_type:
                  type: string
                  minLength: 1
                  maxLength: 100
                status:
                  type: string
                  enum:
                    - Scheduled
                    - Confirmed
                    - Completed
                    - No-show
                    - Cancelled
                scheduled_at:
                  type: string
                  format: date-time
                location:
                  type: string
                  maxLength: 500
                provider:
                  type: string
                  maxLength: 255
                notes:
                  type: string
                  maxLength: 5000
                  nullable: true
      responses:
        "200":
          description: Updated appointment
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      id:
                        type: string
                        format: uuid
                      status:
                        type: string
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
    delete:
      operationId: deletePlatformAppointment
      summary: Delete appointment
      tags:
        - Platform
      security:
        - BearerAuth: []
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Appointment ID
      responses:
        "200":
          description: Deleted
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: object
                    properties:
                      deleted:
                        type: boolean
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "404":
          description: Not found
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
  /api/platform/devices/{deviceId}/generate-steps:
    post:
      operationId: generateDeviceStepsFromPdf
      summary: AI-generate onboarding steps from instruction PDF
      tags:
        - Platform
      description: "One-time operation: fetches the uploaded PDF, extracts text, sends to GPT-4o, and inserts generated
        device_onboarding_steps. Returns 409 if steps already exist."
      security:
        - BearerAuth: []
      parameters:
        - name: deviceId
          in: path
          required: true
          schema:
            type: string
            format: uuid
          description: Device ID
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - instruction_pdf_url
              properties:
                instruction_pdf_url:
                  type: string
                  format: uri
                  description: Public URL of the uploaded instruction PDF
      responses:
        "200":
          description: Generated onboarding steps
          content:
            application/json:
              schema:
                type: object
                required:
                  - data
                properties:
                  data:
                    type: array
                    items:
                      $ref: "#/components/schemas/DeviceOnboardingStep"
        "400":
          description: Bad request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "403":
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "409":
          description: Conflict
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
        "502":
          description: Bad gateway (upstream error)
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ErrorResponse"
