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

# Export Cohort Patients

> Export-shaped page of a cohort's membership.

Resolved server-side from ``filter_criteria`` so both cohort kinds (dynamic
filters and custom lists) export the exact membership the cohort resolves to
— the patient table can't express a custom list. Paged (not one dump) because
production cohorts run to thousands of patients. Ignores ``query_params.sort_by``
— export paging always uses the stable name/id order below, since re-sorting
a wide PII export isn't a feature this endpoint offers.



## OpenAPI

````yaml get /comms/cohorts/{cohort_id}/export
openapi: 3.1.0
info:
  title: Decoda API
  description: External API documentation for the Decoda Health platform.
  version: '1.0'
servers: []
security: []
paths:
  /comms/cohorts/{cohort_id}/export:
    get:
      tags:
        - Audience Cohorts
      summary: Export Cohort Patients
      description: >-
        Export-shaped page of a cohort's membership.


        Resolved server-side from ``filter_criteria`` so both cohort kinds
        (dynamic

        filters and custom lists) export the exact membership the cohort
        resolves to

        — the patient table can't express a custom list. Paged (not one dump)
        because

        production cohorts run to thousands of patients. Ignores
        ``query_params.sort_by``

        — export paging always uses the stable name/id order below, since
        re-sorting

        a wide PII export isn't a feature this endpoint offers.
      operationId: export_cohort_patients_comms_cohorts__cohort_id__export_get
      parameters:
        - name: TENANT
          in: header
          required: true
          schema:
            type: string
            title: Tenant
          description: The tenant you are making this request on behalf of
        - name: API-KEY
          in: header
          required: true
          schema:
            type: string
            title: Api-Key
          description: Your api key
        - name: cohort_id
          in: path
          required: true
          schema:
            type: string
            title: Cohort Id
        - name: page
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Page
        - name: per_page
          in: query
          required: false
          schema:
            anyOf:
              - type: integer
              - type: 'null'
            title: Per Page
        - name: sort_by
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Sort By
        - name: sort_direction
          in: query
          required: false
          schema:
            anyOf:
              - enum:
                  - asc
                  - desc
                type: string
              - type: 'null'
            title: Sort Direction
        - name: location_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Location Id
        - name: id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Id
        - name: external_id
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: External Id
        - name: name
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Name
        - name: email
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Email
        - name: phone_number
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Phone Number
        - name: date_of_birth
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: string
                type: array
              - type: 'null'
            title: Date Of Birth
        - name: birthday
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Birthday
        - name: created_date
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: string
                type: array
              - additionalProperties: true
                type: object
              - type: 'null'
            title: Created Date
        - name: tag_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by patient tag IDs
            title: Tag Ids
          description: Filter by patient tag IDs
        - name: tag_ids_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients with ANY of these tag IDs
            title: Tag Ids Exclude
          description: Exclude patients with ANY of these tag IDs
        - name: tag_ids_mode
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                enum:
                  - any
                  - all
              - type: 'null'
            description: >-
              Match mode for tag_ids: 'any' (has ANY) or 'all' (has ALL).
              Default: 'all'
            title: Tag Ids Mode
          description: >-
            Match mode for tag_ids: 'any' (has ANY) or 'all' (has ALL). Default:
            'all'
        - name: location_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by primary location IDs
            title: Location Ids
          description: Filter by primary location IDs
        - name: location_ids_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients at these location IDs
            title: Location Ids Exclude
          description: Exclude patients at these location IDs
        - name: lead_source
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by lead source
            title: Lead Source
          description: Filter by lead source
        - name: lead_source_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients with these lead sources
            title: Lead Source Exclude
          description: Exclude patients with these lead sources
        - name: tz
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Tz
        - name: sms_opt_out
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by combined SMS opt-out status ('true' or 'false')
            title: Sms Opt Out
          description: Filter by combined SMS opt-out status ('true' or 'false')
        - name: on_scheduling_blacklist
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by scheduling blacklist status ('true' or 'false')
            title: On Scheduling Blacklist
          description: Filter by scheduling blacklist status ('true' or 'false')
        - name: opted_in_to_sms_marketing
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Filter by SMS marketing opt-in status ('true', 'false', or
              'not_set')
            title: Opted In To Sms Marketing
          description: >-
            Filter by SMS marketing opt-in status ('true', 'false', or
            'not_set')
        - name: opted_in_to_email_marketing
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Filter by email marketing opt-in status ('true', 'false', or
              'not_set')
            title: Opted In To Email Marketing
          description: >-
            Filter by email marketing opt-in status ('true', 'false', or
            'not_set')
        - name: opted_in_to_social_media
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by social media consent status ('true' or 'false')
            title: Opted In To Social Media
          description: Filter by social media consent status ('true' or 'false')
        - name: appointment_count
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by appointment count [min, max], null = unbounded
            title: Appointment Count
          description: Filter by appointment count [min, max], null = unbounded
        - name: last_appointment_days
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by days since last appointment [min, max], null = unbounded
            title: Last Appointment Days
          description: Filter by days since last appointment [min, max], null = unbounded
        - name: last_appointment_service_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Scope the 'time since last appointment' recency to these service
              IDs. Omit to measure recency across all appointments.
            title: Last Appointment Service Ids
          description: >-
            Scope the 'time since last appointment' recency to these service
            IDs. Omit to measure recency across all appointments.
        - name: visit_span_days
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: >-
              Filter by visit span in days (last appointment − first
              appointment) [min, max], null = unbounded
            title: Visit Span Days
          description: >-
            Filter by visit span in days (last appointment − first appointment)
            [min, max], null = unbounded
        - name: total_spent
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by total spent in cents [min, max], null = unbounded
            title: Total Spent
          description: Filter by total spent in cents [min, max], null = unbounded
        - name: membership_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by active membership IDs
            title: Membership Ids
          description: Filter by active membership IDs
        - name: membership_ids_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients with these active memberships
            title: Membership Ids Exclude
          description: Exclude patients with these active memberships
        - name: membership_ids_mode
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                enum:
                  - any
                  - all
              - type: 'null'
            description: 'Match mode for membership_ids: ''any'' or ''all''. Default: ''any'''
            title: Membership Ids Mode
          description: 'Match mode for membership_ids: ''any'' or ''all''. Default: ''any'''
        - name: enrolled_membership_date_range
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: string
                type: array
              - additionalProperties: true
                type: object
              - type: 'null'
            description: >-
              Window [start, end] in which a membership enrollment must have
              STARTED (member.start_date), in any status. Narrowed to specific
              memberships when enrolled_membership_ids is set.
            title: Enrolled Membership Date Range
          description: >-
            Window [start, end] in which a membership enrollment must have
            STARTED (member.start_date), in any status. Narrowed to specific
            memberships when enrolled_membership_ids is set.
        - name: enrolled_membership_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Membership IDs the patient must have enrolled in within
              enrolled_membership_date_range. Omit to match an enrollment in any
              membership in the window.
            title: Enrolled Membership Ids
          description: >-
            Membership IDs the patient must have enrolled in within
            enrolled_membership_date_range. Omit to match an enrollment in any
            membership in the window.
        - name: membership_anniversary
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Year-agnostic enrollment anniversary: ['--MM-DD', '--MM-DD']
              month/day range matching member.start_date in ANY year and ANY
              status.
            title: Membership Anniversary
          description: >-
            Year-agnostic enrollment anniversary: ['--MM-DD', '--MM-DD']
            month/day range matching member.start_date in ANY year and ANY
            status.
        - name: membership_anniversary_membership_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Membership IDs the anniversary must belong to. Omit to match an
              enrollment anniversary in any membership.
            title: Membership Anniversary Membership Ids
          description: >-
            Membership IDs the anniversary must belong to. Omit to match an
            enrollment anniversary in any membership.
        - name: package_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by active package IDs
            title: Package Ids
          description: Filter by active package IDs
        - name: package_ids_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients with these active packages
            title: Package Ids Exclude
          description: Exclude patients with these active packages
        - name: package_ids_mode
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                enum:
                  - any
                  - all
              - type: 'null'
            description: 'Match mode for package_ids: ''any'' or ''all''. Default: ''any'''
            title: Package Ids Mode
          description: 'Match mode for package_ids: ''any'' or ''all''. Default: ''any'''
        - name: appointment_type_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by service IDs from completed appointments
            title: Appointment Type Ids
          description: Filter by service IDs from completed appointments
        - name: appointment_type_ids_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients who completed these appointment types
            title: Appointment Type Ids Exclude
          description: Exclude patients who completed these appointment types
        - name: appointment_type_ids_mode
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                enum:
                  - any
                  - all
              - type: 'null'
            description: >-
              Match mode for appointment_type_ids: 'any' or 'all'. Default:
              'any'
            title: Appointment Type Ids Mode
          description: 'Match mode for appointment_type_ids: ''any'' or ''all''. Default: ''any'''
        - name: appointment_date_range
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: string
                type: array
              - additionalProperties: true
                type: object
              - type: 'null'
            description: Filter by appointment date range [start, end]
            title: Appointment Date Range
          description: Filter by appointment date range [start, end]
        - name: appointment_service_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Restrict appointment_date_range to appointments for these service
              IDs. Omit to match any appointment in the window.
            title: Appointment Service Ids
          description: >-
            Restrict appointment_date_range to appointments for these service
            IDs. Omit to match any appointment in the window.
        - name: appointment_statuses
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  $ref: '#/components/schemas/EventStatus'
                type: array
              - type: 'null'
            description: >-
              Appointment statuses that count inside appointment_date_range.
              Omit both this and appointment_statuses_exclude to count every
              status except CANCELLED.
            title: Appointment Statuses
          description: >-
            Appointment statuses that count inside appointment_date_range. Omit
            both this and appointment_statuses_exclude to count every status
            except CANCELLED.
        - name: appointment_statuses_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  $ref: '#/components/schemas/EventStatus'
                type: array
              - type: 'null'
            description: >-
              Appointment statuses that do NOT count inside
              appointment_date_range. ANDs with appointment_statuses when both
              are set; omitting both excludes CANCELLED only.
            title: Appointment Statuses Exclude
          description: >-
            Appointment statuses that do NOT count inside
            appointment_date_range. ANDs with appointment_statuses when both are
            set; omitting both excludes CANCELLED only.
        - name: completed_appointment_service_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Service IDs that must have been COMPLETED within
              completed_appointment_date_range. Omit to match any completed
              appointment in the window.
            title: Completed Appointment Service Ids
          description: >-
            Service IDs that must have been COMPLETED within
            completed_appointment_date_range. Omit to match any completed
            appointment in the window.
        - name: completed_appointment_date_range
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: string
                type: array
              - additionalProperties: true
                type: object
              - type: 'null'
            description: >-
              Window [start, end] in which an appointment must have been
              COMPLETED. Narrowed to specific services when
              completed_appointment_service_ids is set.
            title: Completed Appointment Date Range
          description: >-
            Window [start, end] in which an appointment must have been
            COMPLETED. Narrowed to specific services when
            completed_appointment_service_ids is set.
        - name: created_appointment_service_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Service IDs that must have been BOOKED within
              created_appointment_date_range. Omit to match any appointment
              booked in the window.
            title: Created Appointment Service Ids
          description: >-
            Service IDs that must have been BOOKED within
            created_appointment_date_range. Omit to match any appointment booked
            in the window.
        - name: created_appointment_date_range
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: string
                type: array
              - additionalProperties: true
                type: object
              - type: 'null'
            description: >-
              Window [start, end] in which an appointment must have been BOOKED
              (created), keyed on the appointment's creation timestamp rather
              than its scheduled date. Narrowed to specific services when
              created_appointment_service_ids is set.
            title: Created Appointment Date Range
          description: >-
            Window [start, end] in which an appointment must have been BOOKED
            (created), keyed on the appointment's creation timestamp rather than
            its scheduled date. Narrowed to specific services when
            created_appointment_service_ids is set.
        - name: no_appointment_service_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Restrict no_appointment_date_range to appointments for these
              service IDs. Omit to match any appointment in the window.
            title: No Appointment Service Ids
          description: >-
            Restrict no_appointment_date_range to appointments for these service
            IDs. Omit to match any appointment in the window.
        - name: no_appointment_date_range
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: string
                type: array
              - additionalProperties: true
                type: object
              - type: 'null'
            description: >-
              Patients with NO non-cancelled appointment (optionally for
              no_appointment_service_ids) in this date range [start, end]
            title: No Appointment Date Range
          description: >-
            Patients with NO non-cancelled appointment (optionally for
            no_appointment_service_ids) in this date range [start, end]
        - name: weight
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: number
                    - type: 'null'
                type: array
              - type: 'null'
            title: Weight
            description: Filter by latest weight in lbs [min, max], null = unbounded
          description: Filter by latest weight in lbs [min, max], null = unbounded
        - name: gender
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            title: Gender
            description: Filter by gender values
          description: Filter by gender values
        - name: gender_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients with these genders
            title: Gender Exclude
          description: Exclude patients with these genders
        - name: patient_source
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by patient source
            title: Patient Source
          description: Filter by patient source
        - name: patient_source_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients from these sources
            title: Patient Source Exclude
          description: Exclude patients from these sources
        - name: preferred_provider_id
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by preferred provider IDs
            title: Preferred Provider Id
          description: Filter by preferred provider IDs
        - name: preferred_provider_id_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients with these preferred providers
            title: Preferred Provider Id Exclude
          description: Exclude patients with these preferred providers
        - name: most_recent_provider_id
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by provider IDs from most recent completed appointment
            title: Most Recent Provider Id
          description: Filter by provider IDs from most recent completed appointment
        - name: most_recent_provider_id_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Exclude patients whose most recent completed appointment was with
              these providers
            title: Most Recent Provider Id Exclude
          description: >-
            Exclude patients whose most recent completed appointment was with
            these providers
        - name: credit_balance
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by credit balance in cents [min, max]
            title: Credit Balance
          description: Filter by credit balance in cents [min, max]
        - name: hide_unconverted_leads
          in: query
          required: false
          schema:
            type: boolean
            description: >-
              Hide patients that are thin comms identities for open
              opportunities (default: True)
            default: true
            title: Hide Unconverted Leads
          description: >-
            Hide patients that are thin comms identities for open opportunities
            (default: True)
        - name: city
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: City
        - name: state
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: State
        - name: zip_code
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Zip Code
        - name: last_active_days
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by days since last active [min, max]
            title: Last Active Days
          description: Filter by days since last active [min, max]
        - name: opted_out_of_email
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by email opt-out status ('true' or 'false')
            title: Opted Out Of Email
          description: Filter by email opt-out status ('true' or 'false')
        - name: age
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            title: Age
            description: Filter by current age in years [min, max], null = unbounded
          description: Filter by current age in years [min, max], null = unbounded
        - name: height
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: number
                    - type: 'null'
                type: array
              - type: 'null'
            title: Height
            description: Filter by latest height in inches [min, max], null = unbounded
          description: Filter by latest height in inches [min, max], null = unbounded
        - name: goal_weight
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: number
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by goal weight in lbs [min, max], null = unbounded
            title: Goal Weight
          description: Filter by goal weight in lbs [min, max], null = unbounded
        - name: systolic_bp
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: number
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by latest systolic BP in mmHg [min, max], null = unbounded
            title: Systolic Bp
          description: Filter by latest systolic BP in mmHg [min, max], null = unbounded
        - name: diastolic_bp
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: number
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by latest diastolic BP in mmHg [min, max], null = unbounded
            title: Diastolic Bp
          description: Filter by latest diastolic BP in mmHg [min, max], null = unbounded
        - name: waist_circumference
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: number
                    - type: 'null'
                type: array
              - type: 'null'
            description: >-
              Filter by latest waist circumference in inches [min, max], null =
              unbounded
            title: Waist Circumference
          description: >-
            Filter by latest waist circumference in inches [min, max], null =
            unbounded
        - name: pulse
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: number
                    - type: 'null'
                type: array
              - type: 'null'
            title: Pulse
            description: Filter by latest pulse in BPM [min, max], null = unbounded
          description: Filter by latest pulse in BPM [min, max], null = unbounded
        - name: temperature
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: number
                    - type: 'null'
                type: array
              - type: 'null'
            title: Temperature
            description: Filter by latest temperature in °F [min, max], null = unbounded
          description: Filter by latest temperature in °F [min, max], null = unbounded
        - name: has_profile_picture
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by profile picture presence ('true' or 'false')
            title: Has Profile Picture
          description: Filter by profile picture presence ('true' or 'false')
        - name: pronouns
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            title: Pronouns
            description: Filter by pronouns text
          description: Filter by pronouns text
        - name: preferred_name
          in: query
          required: false
          schema:
            anyOf:
              - type: string
              - type: 'null'
            description: Filter by preferred name text
            title: Preferred Name
          description: Filter by preferred name text
        - name: surcharge_disabled
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by surcharge disabled status ('true' or 'false')
            title: Surcharge Disabled
          description: Filter by surcharge disabled status ('true' or 'false')
        - name: has_notes
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by note presence ('true' or 'false')
            title: Has Notes
          description: Filter by note presence ('true' or 'false')
        - name: has_active_chat
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by active chat presence ('true' or 'false')
            title: Has Active Chat
          description: Filter by active chat presence ('true' or 'false')
        - name: medication_count
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by active medication count [min, max], null = unbounded
            title: Medication Count
          description: Filter by active medication count [min, max], null = unbounded
        - name: has_email
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by email presence ('true' or 'false')
            title: Has Email
          description: Filter by email presence ('true' or 'false')
        - name: has_phone_number
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by phone number presence ('true' or 'false')
            title: Has Phone Number
          description: Filter by phone number presence ('true' or 'false')
        - name: has_membership
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Filter by active, frozen, or delinquent membership presence
              ('true' or 'false')
            title: Has Membership
          description: >-
            Filter by active, frozen, or delinquent membership presence ('true'
            or 'false')
        - name: has_tags
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by tag presence ('true' or 'false')
            title: Has Tags
          description: Filter by tag presence ('true' or 'false')
        - name: has_future_appointments
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by future appointment presence ('true' or 'false')
            title: Has Future Appointments
          description: Filter by future appointment presence ('true' or 'false')
        - name: cancelled_appointment_date_range
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: string
                      format: date-time
                    - type: string
                type: array
              - additionalProperties: true
                type: object
              - type: 'null'
            description: Filter by cancelled appointment date range [start, end]
            title: Cancelled Appointment Date Range
          description: Filter by cancelled appointment date range [start, end]
        - name: cancelled_appointment_days
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Days since last cancelled appointment [min, max], null = unbounded
            title: Cancelled Appointment Days
          description: Days since last cancelled appointment [min, max], null = unbounded
        - name: last_appointment_status
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Status of patient's most recent appointment
            title: Last Appointment Status
          description: Status of patient's most recent appointment
        - name: outstanding_balance
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by outstanding balance in cents [min, max]
            title: Outstanding Balance
          description: Filter by outstanding balance in cents [min, max]
        - name: outstanding_balance_days
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by days since oldest outstanding charge [min, max]
            title: Outstanding Balance Days
          description: Filter by days since oldest outstanding charge [min, max]
        - name: purchased_item_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by purchased item IDs from charges
            title: Purchased Item Ids
          description: Filter by purchased item IDs from charges
        - name: purchased_item_ids_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Exclude patients who purchased these items
            title: Purchased Item Ids Exclude
          description: Exclude patients who purchased these items
        - name: purchased_item_ids_mode
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                enum:
                  - any
                  - all
              - type: 'null'
            description: 'Match mode for purchased_item_ids: ''any'' or ''all''. Default: ''any'''
            title: Purchased Item Ids Mode
          description: 'Match mode for purchased_item_ids: ''any'' or ''all''. Default: ''any'''
        - name: has_payment_plan
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by payment plan presence ('true' or 'false')
            title: Has Payment Plan
          description: Filter by payment plan presence ('true' or 'false')
        - name: last_payment_days
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  anyOf:
                    - type: integer
                    - type: 'null'
                type: array
              - type: 'null'
            description: Filter by days since last successful payment [min, max]
            title: Last Payment Days
          description: Filter by days since last successful payment [min, max]
        - name: last_payment_status
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  $ref: '#/components/schemas/PaymentStatus'
                type: array
              - type: 'null'
            description: Status of patient's most recent payment
            title: Last Payment Status
          description: Status of patient's most recent payment
        - name: last_payment_status_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  $ref: '#/components/schemas/PaymentStatus'
                type: array
              - type: 'null'
            description: Exclude patients whose last payment status matches
            title: Last Payment Status Exclude
          description: Exclude patients whose last payment status matches
        - name: has_payment_method
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: Filter by saved payment method presence ('true' or 'false')
            title: Has Payment Method
          description: Filter by saved payment method presence ('true' or 'false')
        - name: membership_statuses
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  $ref: '#/components/schemas/MemberStatus'
                type: array
              - type: 'null'
            description: Filter by membership status values
            title: Membership Statuses
          description: Filter by membership status values
        - name: membership_statuses_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  $ref: '#/components/schemas/MemberStatus'
                type: array
              - type: 'null'
            description: Exclude patients with memberships in these statuses
            title: Membership Statuses Exclude
          description: Exclude patients with memberships in these statuses
        - name: membership_statuses_membership_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Narrow membership_statuses / membership_statuses_exclude to these
              memberships. Omit to match a membership in those statuses
              regardless of plan.
            title: Membership Statuses Membership Ids
          description: >-
            Narrow membership_statuses / membership_statuses_exclude to these
            memberships. Omit to match a membership in those statuses regardless
            of plan.
        - name: discount_types
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  $ref: '#/components/schemas/DiscountType'
                type: array
              - type: 'null'
            description: >-
              Filter by patients who hold a currently-redeemable discount of
              these source types (e.g. MEMBERSHIP, PACKAGE, PROMOTION)
            title: Discount Types
          description: >-
            Filter by patients who hold a currently-redeemable discount of these
            source types (e.g. MEMBERSHIP, PACKAGE, PROMOTION)
        - name: discount_types_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  $ref: '#/components/schemas/DiscountType'
                type: array
              - type: 'null'
            description: >-
              Exclude patients who hold a currently-redeemable discount of these
              source types
            title: Discount Types Exclude
          description: >-
            Exclude patients who hold a currently-redeemable discount of these
            source types
        - name: discount_template_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Filter by patients who hold a currently-redeemable discount from
              these discount templates
            title: Discount Template Ids
          description: >-
            Filter by patients who hold a currently-redeemable discount from
            these discount templates
        - name: discount_template_ids_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Exclude patients who hold a currently-redeemable discount from
              these discount templates
            title: Discount Template Ids Exclude
          description: >-
            Exclude patients who hold a currently-redeemable discount from these
            discount templates
        - name: discount_template_ids_mode
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                enum:
                  - any
                  - all
              - type: 'null'
            description: >-
              Match mode for discount_template_ids: 'any' or 'all'. Default:
              'any'
            title: Discount Template Ids Mode
          description: 'Match mode for discount_template_ids: ''any'' or ''all''. Default: ''any'''
        - name: discount_benefit_item_ids
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Filter by patients who hold a currently-redeemable discount
              targeting these items (e.g. a Nutrition consult included in their
              package/membership)
            title: Discount Benefit Item Ids
          description: >-
            Filter by patients who hold a currently-redeemable discount
            targeting these items (e.g. a Nutrition consult included in their
            package/membership)
        - name: discount_benefit_item_ids_exclude
          in: query
          required: false
          schema:
            anyOf:
              - items:
                  type: string
                type: array
              - type: 'null'
            description: >-
              Exclude patients who hold a currently-redeemable discount
              targeting these items
            title: Discount Benefit Item Ids Exclude
          description: >-
            Exclude patients who hold a currently-redeemable discount targeting
            these items
        - name: discount_benefit_item_ids_mode
          in: query
          required: false
          schema:
            anyOf:
              - type: string
                enum:
                  - any
                  - all
              - type: 'null'
            description: >-
              Match mode for discount_benefit_item_ids: 'any' or 'all'. Default:
              'any'
            title: Discount Benefit Item Ids Mode
          description: >-
            Match mode for discount_benefit_item_ids: 'any' or 'all'. Default:
            'any'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Page_CohortExportPatient_'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    EventStatus:
      type: string
      enum:
        - PENDING
        - RESERVED
        - CONFIRMED
        - CANCELLED
        - COMPLETED
        - OVERRIDABLE
        - NO_SHOW
      title: EventStatus
    PaymentStatus:
      type: string
      enum:
        - CANCELED
        - CREATED
        - FAILED
        - IN_REVIEW
        - PRESENTING
        - PROCESSING
        - SUCCEEDED
      title: PaymentStatus
      description: >-
        Status of a Payment or Refund.


        NOTE for any "cash collected / refunded" or settlement-style query:

        both ``SUCCEEDED`` AND ``PROCESSING`` count as money committed.
        ``SUCCEEDED``

        means cleared in the bank account; ``PROCESSING`` means the transaction
        is

        in flight (e.g. ACH still settling) but the clinic should expect it.
        Most

        accounting / analytics aggregates that filter only on ``status ==
        SUCCEEDED``

        silently undercount real cash flow — use ``status IN (SUCCEEDED,
        PROCESSING)``

        unless you specifically want only fully-cleared funds.


        Use ``COMMITTED_PAYMENT_STATUSES`` below for the common case.
    MemberStatus:
      type: string
      enum:
        - ACTIVE
        - EXPIRED
        - CANCELLED
        - DELINQUENT
        - FROZEN
        - INACTIVE
        - PENDING
        - AWAITING_FORM
        - SWITCHED
      title: MemberStatus
    DiscountType:
      type: string
      enum:
        - GLOBAL
        - CUSTOM
        - MEMBERSHIP
        - PACKAGE
        - SAVED_ITEM
        - PROMOTION
        - CASH_DISCOUNT
      title: DiscountType
    Page_CohortExportPatient_:
      properties:
        data:
          items:
            $ref: '#/components/schemas/CohortExportPatient'
          type: array
          title: Data
        total:
          type: integer
          title: Total
      type: object
      required:
        - data
        - total
      title: Page[CohortExportPatient]
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    CohortExportPatient:
      properties:
        id:
          type: string
          title: Id
        externalId:
          anyOf:
            - type: string
            - type: 'null'
          title: Externalid
        firstName:
          anyOf:
            - type: string
            - type: 'null'
          title: Firstname
        lastName:
          anyOf:
            - type: string
            - type: 'null'
          title: Lastname
        dateOfBirth:
          anyOf:
            - type: string
              format: date
            - type: 'null'
          title: Dateofbirth
        gender:
          anyOf:
            - type: string
            - type: 'null'
          title: Gender
        email:
          anyOf:
            - type: string
            - type: 'null'
          title: Email
        phoneNumber:
          anyOf:
            - type: string
            - type: 'null'
          title: Phonenumber
        address:
          anyOf:
            - type: string
            - type: 'null'
          title: Address
        addressLineTwo:
          anyOf:
            - type: string
            - type: 'null'
          title: Addresslinetwo
        city:
          anyOf:
            - type: string
            - type: 'null'
          title: City
        state:
          anyOf:
            - type: string
            - type: 'null'
          title: State
        zipCode:
          anyOf:
            - type: string
            - type: 'null'
          title: Zipcode
        primaryLocationName:
          anyOf:
            - type: string
            - type: 'null'
          title: Primarylocationname
        optedInToSmsMarketing:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Optedintosmsmarketing
        optedInToEmailMarketing:
          anyOf:
            - type: boolean
            - type: 'null'
          title: Optedintoemailmarketing
        createdDate:
          anyOf:
            - type: string
              format: date-time
            - type: 'null'
          title: Createddate
      type: object
      required:
        - id
      title: CohortExportPatient
      description: >-
        Row shape for a cohort export — identity, contact, address and marketing
        consent.


        Wider than ``CohortPatient`` (which backs the in-app preview table)
        because an

        export feeds mail-merge and ad-platform uploads, and read straight off
        the

        patient row so the projection stays a single column select at cohort
        scale.
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError

````