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

# Create a Continuous Query

> Post org team continuous query via the Junction API. Requires authentication with your team API key.

<Card horizontal icon="person-digging" color="#57164A">
  Junction Sense is in **closed beta**.

  Interested in Junction Sense? Get in touch with your Customer Success Manager.
</Card>

<Info>
  [Junction Management API](/api-details/junction-management-api) is available for [the Scale plan](https://tryvital.io/pricing).
</Info>

<Tip>
  The base URL of this endpoint is `https://api.management.junction.com/`.

  The endpoint accepts only [Management Key](/api-details/junction-management-api#authentication) (`X-Management-Key`).
  Team API Key is not accepted.
</Tip>


## OpenAPI

````yaml post /v1/org/{org_id}/team/{team_id}/{environment}/continuous_query
openapi: 3.1.0
info:
  title: Org Management
  version: 0.1.0
servers:
  - url: https://api.management.junction.com
    description: Production Management API server
security:
  - ManagementKey: []
paths:
  /v1/org/{org_id}/team/{team_id}/{environment}/continuous_query:
    post:
      tags:
        - Team Continuous Query
      summary: Create Continuous Query
      operationId: >-
        create_continuous_query_v1_org__org_id__team__team_id___environment__continuous_query_post
      parameters:
        - name: org_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Org Id
        - name: team_id
          in: path
          required: true
          schema:
            type: string
            format: uuid
            title: Team Id
        - name: environment
          in: path
          required: true
          schema:
            $ref: '#/components/schemas/Env'
        - name: query_type
          in: query
          required: false
          schema:
            enum:
              - team
              - platform
            type: string
            default: team
            title: Query Type
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateContinuousQueryBody'
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ContinuousQuery'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
components:
  schemas:
    Env:
      type: string
      enum:
        - production
        - sandbox
      title: Env
    CreateContinuousQueryBody:
      properties:
        slug:
          type: string
          pattern: ^(?!.*--)(?!.*-$)(?!-.*$)[a-z0-9-]{1,128}$
          title: Slug
        title:
          type: string
          pattern: ^[A-Za-zÀ-ÖØ-öø-ÿ0-9()&_\-.\s]{0,50}$
          title: Title
        query:
          $ref: '#/components/schemas/Query-Input'
        query_config:
          $ref: '#/components/schemas/QueryConfig'
        scheduling_preferences:
          $ref: '#/components/schemas/ContinuousQuerySchedulingPreferences'
        export_preferences:
          $ref: '#/components/schemas/ContinuousQueryExportPreferences'
      type: object
      required:
        - slug
        - title
        - query
      title: CreateContinuousQueryBody
      example:
        export_preferences:
          data_events:
            enabled: true
        query:
          group_by:
            - arg:
                index: sleep
              date_trunc:
                unit: month
                value: 1
          select:
            - group_key: '*'
            - arg:
                value_macro: sleep_score
                version: automatic
              func: mean
        query_config:
          provider_priority_overrides:
            - oura
        scheduling_preferences:
          minimum_gap_duration_second: 3600
        slug: weekly_mean_sleep_score
        title: Weekly Mean Sleep Score
    ContinuousQuery:
      properties:
        id:
          type: string
          format: uuid
          title: Id
        status:
          $ref: '#/components/schemas/ContinuousQueryStatus'
        slug:
          type: string
          title: Slug
        title:
          type: string
          title: Title
        team_id:
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
          title: Team Id
        query:
          $ref: '#/components/schemas/Query-Output'
        query_config:
          $ref: '#/components/schemas/QueryConfig'
        scheduling_preferences:
          $ref: '#/components/schemas/ContinuousQuerySchedulingPreferences'
        result_table_schema:
          additionalProperties: true
          type: object
          title: Result Table Schema
        resource_dependencies:
          items:
            $ref: '#/components/schemas/Resource'
          type: array
          title: Resource Dependencies
        export_preferences:
          $ref: '#/components/schemas/ContinuousQueryExportPreferences'
        fhir_observation_mappers:
          items:
            type: string
            enum:
              - vital-signs#29463-7#junction-body-weight-1
              - vital-signs#8867-4#junction-heart-rate-1
              - vital-signs#9279-1#junction-respiration-rate-1
          type: array
          title: Fhir Observation Mappers
          default: []
      type: object
      required:
        - id
        - status
        - slug
        - title
        - query
        - scheduling_preferences
        - result_table_schema
        - resource_dependencies
        - export_preferences
      title: ContinuousQuery
      example:
        export_preferences:
          data_events:
            enabled: true
        id: d25f4472-c679-4e7a-9442-2bce8c12afb1
        query:
          group_by:
            - arg:
                index: sleep
              date_trunc:
                unit: month
                value: 1
          select:
            - group_key: '*'
            - arg:
                value_macro: sleep_score
                version: automatic
              func: mean
        query_config:
          provider_priority_overrides:
            - oura
        resource_dependencies:
          - sleep
        result_table_schema:
          group_key.0: string
          sleep_score: int64
        scheduling_preferences:
          minimum_gap_duration_second: 3600
        slug: weekly_mean_sleep_score
        title: Weekly Mean Sleep Score
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    Query-Input:
      properties:
        select:
          items:
            anyOf:
              - $ref: '#/components/schemas/AggregateExpr-Input'
              - $ref: '#/components/schemas/GroupKeyColumnExpr'
              - $ref: '#/components/schemas/SleepColumnExpr'
              - $ref: '#/components/schemas/DerivedReadinessColumnExpr'
              - $ref: '#/components/schemas/ActivityColumnExpr'
              - $ref: '#/components/schemas/WorkoutColumnExpr'
              - $ref: '#/components/schemas/BodyColumnExpr'
              - $ref: '#/components/schemas/MealColumnExpr'
              - $ref: '#/components/schemas/MenstrualCycleColumnExpr'
              - $ref: '#/components/schemas/ProfileColumnExpr'
              - $ref: '#/components/schemas/SleepScoreValueMacroExpr'
              - $ref: '#/components/schemas/ChronotypeValueMacroExpr'
              - $ref: '#/components/schemas/AsleepAtValueMacroExpr'
              - $ref: '#/components/schemas/AwakeAtValueMacroExpr'
              - $ref: '#/components/schemas/AwakeningsValueMacroExpr'
              - $ref: '#/components/schemas/UnrecognizedValueMacroExpr'
              - $ref: '#/components/schemas/DiscreteTimeseriesExpr'
              - $ref: '#/components/schemas/IntervalTimeseriesExpr'
              - $ref: '#/components/schemas/InsulinInjectionTimeseriesExpr'
              - $ref: '#/components/schemas/BloodPressureTimeseriesExpr'
              - $ref: '#/components/schemas/TemperatureTimeseriesExpr'
              - $ref: '#/components/schemas/WorkoutDurationTimeseriesExpr'
              - $ref: '#/components/schemas/NoteTimeseriesExpr'
              - $ref: '#/components/schemas/IndexColumnExpr'
              - $ref: '#/components/schemas/ScalarOutputSubqueryExpr-Input'
              - $ref: '#/components/schemas/SourceColumnExpr'
          type: array
          title: Select
        group_by:
          items:
            anyOf:
              - $ref: '#/components/schemas/DateTruncExpr'
              - $ref: '#/components/schemas/DatePartExpr'
              - $ref: '#/components/schemas/SleepColumnExpr'
              - $ref: '#/components/schemas/DerivedReadinessColumnExpr'
              - $ref: '#/components/schemas/ActivityColumnExpr'
              - $ref: '#/components/schemas/WorkoutColumnExpr'
              - $ref: '#/components/schemas/BodyColumnExpr'
              - $ref: '#/components/schemas/MealColumnExpr'
              - $ref: '#/components/schemas/MenstrualCycleColumnExpr'
              - $ref: '#/components/schemas/ProfileColumnExpr'
              - $ref: '#/components/schemas/SleepScoreValueMacroExpr'
              - $ref: '#/components/schemas/ChronotypeValueMacroExpr'
              - $ref: '#/components/schemas/AsleepAtValueMacroExpr'
              - $ref: '#/components/schemas/AwakeAtValueMacroExpr'
              - $ref: '#/components/schemas/AwakeningsValueMacroExpr'
              - $ref: '#/components/schemas/UnrecognizedValueMacroExpr'
              - $ref: '#/components/schemas/DiscreteTimeseriesExpr'
              - $ref: '#/components/schemas/IntervalTimeseriesExpr'
              - $ref: '#/components/schemas/InsulinInjectionTimeseriesExpr'
              - $ref: '#/components/schemas/BloodPressureTimeseriesExpr'
              - $ref: '#/components/schemas/TemperatureTimeseriesExpr'
              - $ref: '#/components/schemas/WorkoutDurationTimeseriesExpr'
              - $ref: '#/components/schemas/NoteTimeseriesExpr'
              - $ref: '#/components/schemas/SourceColumnExpr'
          type: array
          title: Group By
        where:
          anyOf:
            - type: string
            - type: 'null'
          title: Where
          description: >-
            A WHERE clause filtering the input data. If a GROUP BY clause is
            present, filtering happens prior to GROUP BY evaluation.


            WHERE clause uses SQL Expression syntax to describe the filtering
            criteria:

            * Available operators: `>`, `>=`, `<`, `<=`, `=`, `!=`, `NOT`, `AND`
            and `OR`.

            * Parentheses is supported.
      type: object
      required:
        - select
      title: Query
    QueryConfig:
      properties:
        provider_priority_overrides:
          anyOf:
            - items:
                anyOf:
                  - $ref: '#/components/schemas/Providers'
                  - $ref: '#/components/schemas/Labs'
              type: array
            - type: 'null'
          title: Provider Priority Overrides
      type: object
      title: QueryConfig
    ContinuousQuerySchedulingPreferences:
      properties:
        minimum_gap_duration_second:
          anyOf:
            - type: integer
              minimum: 1800
            - type: 'null'
          title: Minimum Gap Duration Second
      type: object
      title: ContinuousQuerySchedulingPreferences
    ContinuousQueryExportPreferences:
      properties:
        data_events:
          $ref: '#/components/schemas/ContinuousQueryDataEventPreferences'
        fhir_observations:
          type: boolean
          title: Fhir Observations
          default: false
      type: object
      title: ContinuousQueryExportPreferences
    ContinuousQueryStatus:
      type: string
      enum:
        - active
        - archived
      title: ContinuousQueryStatus
    Query-Output:
      properties:
        select:
          items:
            anyOf:
              - $ref: '#/components/schemas/AggregateExpr-Output'
              - $ref: '#/components/schemas/GroupKeyColumnExpr'
              - $ref: '#/components/schemas/SleepColumnExpr'
              - $ref: '#/components/schemas/DerivedReadinessColumnExpr'
              - $ref: '#/components/schemas/ActivityColumnExpr'
              - $ref: '#/components/schemas/WorkoutColumnExpr'
              - $ref: '#/components/schemas/BodyColumnExpr'
              - $ref: '#/components/schemas/MealColumnExpr'
              - $ref: '#/components/schemas/MenstrualCycleColumnExpr'
              - $ref: '#/components/schemas/ProfileColumnExpr'
              - $ref: '#/components/schemas/SleepScoreValueMacroExpr'
              - $ref: '#/components/schemas/ChronotypeValueMacroExpr'
              - $ref: '#/components/schemas/AsleepAtValueMacroExpr'
              - $ref: '#/components/schemas/AwakeAtValueMacroExpr'
              - $ref: '#/components/schemas/AwakeningsValueMacroExpr'
              - $ref: '#/components/schemas/UnrecognizedValueMacroExpr'
              - $ref: '#/components/schemas/DiscreteTimeseriesExpr'
              - $ref: '#/components/schemas/IntervalTimeseriesExpr'
              - $ref: '#/components/schemas/InsulinInjectionTimeseriesExpr'
              - $ref: '#/components/schemas/BloodPressureTimeseriesExpr'
              - $ref: '#/components/schemas/TemperatureTimeseriesExpr'
              - $ref: '#/components/schemas/WorkoutDurationTimeseriesExpr'
              - $ref: '#/components/schemas/NoteTimeseriesExpr'
              - $ref: '#/components/schemas/IndexColumnExpr'
              - $ref: '#/components/schemas/ScalarOutputSubqueryExpr-Output'
              - $ref: '#/components/schemas/SourceColumnExpr'
          type: array
          title: Select
        group_by:
          items:
            anyOf:
              - $ref: '#/components/schemas/DateTruncExpr'
              - $ref: '#/components/schemas/DatePartExpr'
              - $ref: '#/components/schemas/SleepColumnExpr'
              - $ref: '#/components/schemas/DerivedReadinessColumnExpr'
              - $ref: '#/components/schemas/ActivityColumnExpr'
              - $ref: '#/components/schemas/WorkoutColumnExpr'
              - $ref: '#/components/schemas/BodyColumnExpr'
              - $ref: '#/components/schemas/MealColumnExpr'
              - $ref: '#/components/schemas/MenstrualCycleColumnExpr'
              - $ref: '#/components/schemas/ProfileColumnExpr'
              - $ref: '#/components/schemas/SleepScoreValueMacroExpr'
              - $ref: '#/components/schemas/ChronotypeValueMacroExpr'
              - $ref: '#/components/schemas/AsleepAtValueMacroExpr'
              - $ref: '#/components/schemas/AwakeAtValueMacroExpr'
              - $ref: '#/components/schemas/AwakeningsValueMacroExpr'
              - $ref: '#/components/schemas/UnrecognizedValueMacroExpr'
              - $ref: '#/components/schemas/DiscreteTimeseriesExpr'
              - $ref: '#/components/schemas/IntervalTimeseriesExpr'
              - $ref: '#/components/schemas/InsulinInjectionTimeseriesExpr'
              - $ref: '#/components/schemas/BloodPressureTimeseriesExpr'
              - $ref: '#/components/schemas/TemperatureTimeseriesExpr'
              - $ref: '#/components/schemas/WorkoutDurationTimeseriesExpr'
              - $ref: '#/components/schemas/NoteTimeseriesExpr'
              - $ref: '#/components/schemas/SourceColumnExpr'
          type: array
          title: Group By
        where:
          anyOf:
            - type: string
            - type: 'null'
          title: Where
          description: >-
            A WHERE clause filtering the input data. If a GROUP BY clause is
            present, filtering happens prior to GROUP BY evaluation.


            WHERE clause uses SQL Expression syntax to describe the filtering
            criteria:

            * Available operators: `>`, `>=`, `<`, `<=`, `=`, `!=`, `NOT`, `AND`
            and `OR`.

            * Parentheses is supported.
      type: object
      required:
        - select
      title: Query
    Resource:
      type: string
      enum:
        - profile
        - activity
        - sleep
        - body
        - workouts
        - workout_stream
        - connection
        - order
        - result
        - match_review
        - appointment
        - glucose
        - heartrate
        - hrv
        - hrv
        - ige
        - igg
        - blood_oxygen
        - blood_pressure
        - cholesterol
        - device
        - device_legacy
        - weight
        - fat
        - body_temperature
        - body_temperature_delta
        - meal
        - water
        - caffeine
        - mindfulness_minutes
        - steps
        - calories_active
        - distance
        - floors_climbed
        - respiratory_rate
        - vo2_max
        - calories_basal
        - stress_level
        - menstrual_cycle
        - sleep_cycle
        - electrocardiogram
        - electrocardiogram_voltage
        - afib_burden
        - heart_rate_alert
        - stand_hour
        - stand_duration
        - sleep_apnea_alert
        - sleep_breathing_disturbance
        - wheelchair_push
        - forced_expiratory_volume_1
        - forced_vital_capacity
        - peak_expiratory_flow_rate
        - inhaler_usage
        - fall
        - uv_exposure
        - daylight_exposure
        - handwashing
        - basal_body_temperature
        - heart_rate_recovery_one_minute
        - body_mass_index
        - lean_body_mass
        - waist_circumference
        - workout_distance
        - workout_swimming_stroke
        - workout_duration
        - insulin_injection
        - carbohydrates
        - note
        - sleep_stream
        - hypnogram
      title: ClientFacingResource
      x-fern-type-name: ClientFacingResource
    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
    AggregateExpr-Input:
      properties:
        arg:
          anyOf:
            - $ref: '#/components/schemas/SleepColumnExpr'
            - $ref: '#/components/schemas/DerivedReadinessColumnExpr'
            - $ref: '#/components/schemas/ActivityColumnExpr'
            - $ref: '#/components/schemas/WorkoutColumnExpr'
            - $ref: '#/components/schemas/BodyColumnExpr'
            - $ref: '#/components/schemas/MealColumnExpr'
            - $ref: '#/components/schemas/MenstrualCycleColumnExpr'
            - $ref: '#/components/schemas/ProfileColumnExpr'
            - $ref: '#/components/schemas/SleepScoreValueMacroExpr'
            - $ref: '#/components/schemas/ChronotypeValueMacroExpr'
            - $ref: '#/components/schemas/AsleepAtValueMacroExpr'
            - $ref: '#/components/schemas/AwakeAtValueMacroExpr'
            - $ref: '#/components/schemas/AwakeningsValueMacroExpr'
            - $ref: '#/components/schemas/UnrecognizedValueMacroExpr'
            - $ref: '#/components/schemas/DiscreteTimeseriesExpr'
            - $ref: '#/components/schemas/IntervalTimeseriesExpr'
            - $ref: '#/components/schemas/InsulinInjectionTimeseriesExpr'
            - $ref: '#/components/schemas/BloodPressureTimeseriesExpr'
            - $ref: '#/components/schemas/TemperatureTimeseriesExpr'
            - $ref: '#/components/schemas/WorkoutDurationTimeseriesExpr'
            - $ref: '#/components/schemas/NoteTimeseriesExpr'
            - $ref: '#/components/schemas/IndexColumnExpr'
            - $ref: '#/components/schemas/ScalarOutputSubqueryExpr-Input'
          title: Arg
        func:
          type: string
          enum:
            - mean
            - min
            - max
            - sum
            - count
            - median
            - stddev
            - oldest
            - newest
          title: Func
      type: object
      required:
        - arg
        - func
      title: AggregateExpr
    GroupKeyColumnExpr:
      properties:
        group_key:
          anyOf:
            - type: integer
            - type: string
              const: '*'
          title: Group Key
      type: object
      required:
        - group_key
      title: GroupKeyColumnExpr
    SleepColumnExpr:
      properties:
        sleep:
          type: string
          enum:
            - id
            - session_start
            - session_end
            - state
            - type
            - duration_second
            - stage_asleep_second
            - stage_awake_second
            - stage_light_second
            - stage_rem_second
            - stage_deep_second
            - stage_unknown_second
            - latency_second
            - heart_rate_minimum
            - heart_rate_mean
            - heart_rate_maximum
            - heart_rate_dip
            - heart_rate_resting
            - efficiency
            - hrv_mean_rmssd
            - hrv_mean_sdnn
            - skin_temperature
            - skin_temperature_delta
            - respiratory_rate
            - score
            - recovery_readiness_score
            - source_type
            - source_provider
            - source_app_id
            - source_device_id
            - time_zone
          title: Sleep
      type: object
      required:
        - sleep
      title: SleepColumnExpr
    DerivedReadinessColumnExpr:
      properties:
        derived_readiness:
          type: string
          enum:
            - date
            - chronotype
            - sleep_score
            - recovery_score
            - recovery_zone
            - stress_score
            - strain_score
            - strain_zone
          title: Derived Readiness
      type: object
      required:
        - derived_readiness
      title: DerivedReadinessColumnExpr
    ActivityColumnExpr:
      properties:
        activity:
          type: string
          enum:
            - date
            - calories_total
            - calories_active
            - steps
            - distance_meter
            - floors_climbed
            - duration_active_second
            - intensity_sedentary_second
            - intensity_low_second
            - intensity_medium_second
            - intensity_high_second
            - heart_rate_mean
            - heart_rate_minimum
            - heart_rate_maximum
            - heart_rate_resting
            - heart_rate_mean_walking
            - wheelchair_use
            - wheelchair_push
            - source_type
            - source_provider
            - source_app_id
            - source_device_id
            - time_zone
            - time_zone_offset
          title: Activity
      type: object
      required:
        - activity
      title: ActivityColumnExpr
    WorkoutColumnExpr:
      properties:
        workout:
          type: string
          enum:
            - session_start
            - session_end
            - title
            - sport_name
            - sport_slug
            - duration_active_second
            - heart_rate_mean
            - heart_rate_minimum
            - heart_rate_maximum
            - heart_rate_zone_1
            - heart_rate_zone_2
            - heart_rate_zone_3
            - heart_rate_zone_4
            - heart_rate_zone_5
            - heart_rate_zone_6
            - distance_meter
            - calories
            - elevation_gain_meter
            - elevation_maximum_meter
            - elevation_minimum_meter
            - speed_mean
            - speed_maximum
            - power_source
            - power_mean
            - power_maximum
            - power_weighted_mean
            - steps
            - map_polyline
            - map_summary_polyline
            - source_type
            - source_provider
            - source_app_id
            - source_device_id
            - external_id
            - time_zone
          title: Workout
      type: object
      required:
        - workout
      title: WorkoutColumnExpr
    BodyColumnExpr:
      properties:
        body:
          type: string
          enum:
            - measured_at
            - weight_kilogram
            - fat_mass_percentage
            - water_percentage
            - muscle_mass_percentage
            - visceral_fat_index
            - bone_mass_percentage
            - body_mass_index
            - lean_body_mass_kilogram
            - waist_circumference_centimeter
            - source_type
            - source_provider
            - source_app_id
            - source_device_id
            - time_zone
          title: Body
      type: object
      required:
        - body
      title: BodyColumnExpr
    MealColumnExpr:
      properties:
        meal:
          type: string
          enum:
            - calories
            - carbohydrate_gram
            - protein_gram
            - alcohol_gram
            - water_gram
            - fibre_gram
            - sugar_gram
            - cholesterol_gram
            - saturated_fat_gram
            - monounsaturated_fat_gram
            - polyunsaturated_fat_gram
            - omega3_fat_gram
            - omega6_fat_gram
            - total_fat_gram
            - sodium_milligram
            - potassium_milligram
            - calcium_milligram
            - phosphorus_milligram
            - magnesium_milligram
            - iron_milligram
            - zinc_milligram
            - fluoride_milligram
            - chloride_milligram
            - vitamin_a_milligram
            - vitamin_b1_milligram
            - riboflavin_milligram
            - niacin_milligram
            - pantothenic_acid_milligram
            - vitamin_b6_milligram
            - biotin_microgram
            - vitamin_b12_microgram
            - vitamin_c_milligram
            - vitamin_d_microgram
            - vitamin_e_milligram
            - vitamin_k_microgram
            - folic_acid_microgram
            - chromium_microgram
            - copper_milligram
            - iodine_microgram
            - manganese_milligram
            - molybdenum_microgram
            - selenium_microgram
            - date
            - name
            - source_type
            - source_provider
            - source_app_id
            - source_device_id
          title: Meal
      type: object
      required:
        - meal
      title: MealColumnExpr
    MenstrualCycleColumnExpr:
      properties:
        menstrual_cycle:
          type: string
          enum:
            - period_start
            - period_end
            - cycle_end
            - is_predicted
            - menstrual_flow
            - cervical_mucus
            - intermenstrual_bleeding
            - contraceptive
            - detected_deviations
            - ovulation_test
            - home_pregnancy_test
            - home_progesterone_test
            - sexual_activity
            - basal_body_temperature
            - source_type
            - source_provider
            - source_app_id
            - source_device_id
          title: Menstrual Cycle
      type: object
      required:
        - menstrual_cycle
      title: MenstrualCycleColumnExpr
    ProfileColumnExpr:
      properties:
        profile:
          type: string
          enum:
            - height_centimeter
            - birth_date
            - wheelchair_use
            - gender
            - sex
            - source_type
            - source_provider
            - source_app_id
            - source_device_id
            - created_at
            - updated_at
          title: Profile
      type: object
      required:
        - profile
      title: ProfileColumnExpr
    SleepScoreValueMacroExpr:
      properties:
        value_macro:
          type: string
          const: sleep_score
          title: Value Macro
        version:
          type: string
          const: automatic
          title: Version
          default: automatic
      type: object
      required:
        - value_macro
      title: SleepScoreValueMacroExpr
    ChronotypeValueMacroExpr:
      properties:
        value_macro:
          type: string
          const: chronotype
          title: Value Macro
        version:
          type: string
          const: automatic
          title: Version
          default: automatic
      type: object
      required:
        - value_macro
      title: ChronotypeValueMacroExpr
    AsleepAtValueMacroExpr:
      properties:
        value_macro:
          type: string
          const: asleep_at
          title: Value Macro
        version:
          type: string
          const: automatic
          title: Version
          default: automatic
      type: object
      required:
        - value_macro
      title: AsleepAtValueMacroExpr
    AwakeAtValueMacroExpr:
      properties:
        value_macro:
          type: string
          const: awake_at
          title: Value Macro
        version:
          type: string
          const: automatic
          title: Version
          default: automatic
      type: object
      required:
        - value_macro
      title: AwakeAtValueMacroExpr
    AwakeningsValueMacroExpr:
      properties:
        value_macro:
          type: string
          const: awakenings
          title: Value Macro
        version:
          type: string
          const: automatic
          title: Version
          default: automatic
      type: object
      required:
        - value_macro
      title: AwakeningsValueMacroExpr
    UnrecognizedValueMacroExpr:
      properties:
        value_macro:
          type: string
          title: Value Macro
      type: object
      required:
        - value_macro
      title: UnrecognizedValueMacroExpr
    DiscreteTimeseriesExpr:
      properties:
        timeseries:
          type: string
          enum:
            - glucose
            - heartrate
            - hrv
            - ige
            - igg
            - cholesterol
            - weight
            - fat
            - blood_oxygen
            - electrocardiogram_voltage
            - respiratory_rate
            - stress_level
          title: Timeseries
        field:
          anyOf:
            - type: string
              enum:
                - source_provider
                - source_type
            - type: string
              const: source_app_id
            - type: string
              enum:
                - source_workout_id
                - source_sport
            - type: string
              enum:
                - timezone_offset
                - type
            - type: string
              const: value
          title: Field
      type: object
      required:
        - timeseries
        - field
      title: DiscreteTimeseriesExpr
    IntervalTimeseriesExpr:
      properties:
        timeseries:
          type: string
          enum:
            - steps
            - distance
            - vo2_max
            - heart_rate_alert
            - stand_hour
            - sleep_breathing_disturbance
            - water
            - caffeine
            - mindfulness_minutes
            - calories_active
            - floors_climbed
            - calories_basal
            - afib_burden
            - stand_duration
            - sleep_apnea_alert
            - wheelchair_push
            - forced_expiratory_volume_1
            - forced_vital_capacity
            - peak_expiratory_flow_rate
            - inhaler_usage
            - fall
            - uv_exposure
            - daylight_exposure
            - handwashing
            - basal_body_temperature
            - body_mass_index
            - lean_body_mass
            - waist_circumference
            - heart_rate_recovery_one_minute
            - workout_swimming_stroke
            - workout_distance
            - carbohydrates
          title: Timeseries
        field:
          anyOf:
            - type: string
              enum:
                - source_provider
                - source_type
            - type: string
              const: source_app_id
            - type: string
              enum:
                - source_workout_id
                - source_sport
            - type: string
              enum:
                - timezone_offset
                - type
            - type: string
              enum:
                - duration
                - value
          title: Field
      type: object
      required:
        - timeseries
        - field
      title: IntervalTimeseriesExpr
    InsulinInjectionTimeseriesExpr:
      properties:
        timeseries:
          type: string
          const: insulin_injection
          title: Timeseries
        field:
          anyOf:
            - type: string
              enum:
                - source_provider
                - source_type
            - type: string
              const: source_app_id
            - type: string
              enum:
                - source_workout_id
                - source_sport
            - type: string
              enum:
                - timezone_offset
                - type
            - type: string
              enum:
                - duration
                - value
            - type: string
              enum:
                - delivery_mode
                - delivery_form
                - bolus_purpose
          title: Field
      type: object
      required:
        - timeseries
        - field
      title: InsulinInjectionTimeseriesExpr
    BloodPressureTimeseriesExpr:
      properties:
        timeseries:
          type: string
          const: blood_pressure
          title: Timeseries
        field:
          anyOf:
            - type: string
              enum:
                - source_provider
                - source_type
            - type: string
              const: source_app_id
            - type: string
              enum:
                - source_workout_id
                - source_sport
            - type: string
              enum:
                - timezone_offset
                - type
            - type: string
              enum:
                - systolic
                - diastolic
          title: Field
      type: object
      required:
        - timeseries
        - field
      title: BloodPressureTimeseriesExpr
    TemperatureTimeseriesExpr:
      properties:
        timeseries:
          type: string
          enum:
            - body_temperature
            - body_temperature_delta
          title: Timeseries
        field:
          anyOf:
            - type: string
              enum:
                - source_provider
                - source_type
            - type: string
              const: source_app_id
            - type: string
              enum:
                - source_workout_id
                - source_sport
            - type: string
              enum:
                - timezone_offset
                - type
            - type: string
              enum:
                - duration
                - value
            - type: string
              const: sensor_location
          title: Field
      type: object
      required:
        - timeseries
        - field
      title: TemperatureTimeseriesExpr
    WorkoutDurationTimeseriesExpr:
      properties:
        timeseries:
          type: string
          const: workout_duration
          title: Timeseries
        field:
          anyOf:
            - type: string
              enum:
                - source_provider
                - source_type
            - type: string
              const: source_app_id
            - type: string
              enum:
                - source_workout_id
                - source_sport
            - type: string
              enum:
                - timezone_offset
                - type
            - type: string
              enum:
                - duration
                - value
            - type: string
              const: intensity
          title: Field
      type: object
      required:
        - timeseries
        - field
      title: WorkoutDurationTimeseriesExpr
    NoteTimeseriesExpr:
      properties:
        timeseries:
          type: string
          const: note
          title: Timeseries
        field:
          anyOf:
            - type: string
              enum:
                - source_provider
                - source_type
            - type: string
              const: source_app_id
            - type: string
              enum:
                - source_workout_id
                - source_sport
            - type: string
              enum:
                - timezone_offset
                - type
            - type: string
              enum:
                - tags
                - content
          title: Field
      type: object
      required:
        - timeseries
        - field
      title: NoteTimeseriesExpr
    IndexColumnExpr:
      properties:
        index:
          type: string
          enum:
            - sleep
            - derived_readiness
            - activity
            - workout
            - body
            - meal
            - menstrual_cycle
            - profile
            - timeseries
          title: Index
      type: object
      required:
        - index
      title: IndexColumnExpr
    ScalarOutputSubqueryExpr-Input:
      properties:
        select:
          anyOf:
            - $ref: '#/components/schemas/AggregateFieldExpr'
            - $ref: '#/components/schemas/Placeholder'
          title: Select
        from:
          anyOf:
            - $ref: '#/components/schemas/UnnestExpr'
            - $ref: '#/components/schemas/Placeholder'
          title: From
        where:
          anyOf:
            - type: string
            - type: 'null'
          title: Where
      type: object
      required:
        - select
        - from
      title: ScalarOutputSubqueryExpr
      description: A subquery that produces a single scalar value per row.
    SourceColumnExpr:
      properties:
        source:
          anyOf:
            - type: string
              enum:
                - source_provider
                - source_type
            - type: string
              const: source_app_id
            - type: string
              enum:
                - source_workout_id
                - source_sport
          title: Source
      type: object
      required:
        - source
      title: SourceColumnExpr
    DateTruncExpr:
      properties:
        date_trunc:
          $ref: '#/components/schemas/Period'
        arg:
          anyOf:
            - $ref: '#/components/schemas/IndexColumnExpr'
            - $ref: '#/components/schemas/Placeholder'
          title: Arg
      type: object
      required:
        - date_trunc
        - arg
      title: DateTruncExpr
    DatePartExpr:
      properties:
        arg:
          anyOf:
            - $ref: '#/components/schemas/IndexColumnExpr'
            - $ref: '#/components/schemas/Placeholder'
          title: Arg
        date_part:
          anyOf:
            - type: string
              enum:
                - minute
                - hour
                - day
                - week
                - month
                - year
            - type: string
              enum:
                - weekday
                - week_of_year
                - day_of_year
          title: Date Part
      type: object
      required:
        - arg
        - date_part
      title: DatePartExpr
    Providers:
      type: string
      enum:
        - oura
        - fitbit
        - garmin
        - whoop
        - strava
        - renpho
        - peloton
        - wahoo
        - zwift
        - freestyle_libre
        - abbott_libreview
        - tandem_source
        - freestyle_libre_ble
        - eight_sleep
        - withings
        - apple_health_kit
        - manual
        - ihealth
        - google_fit
        - beurer_api
        - beurer_ble
        - omron
        - omron_ble
        - onetouch_ble
        - accuchek_ble
        - contour_ble
        - dexcom
        - dexcom_v3
        - hammerhead
        - my_fitness_pal
        - health_connect
        - samsung_health
        - polar
        - cronometer
        - kardia
        - whoop_v2
        - ultrahuman
        - my_fitness_pal_v2
        - map_my_fitness
        - runkeeper
      title: Providers
    Labs:
      type: string
      enum:
        - ayumetrix
        - spiriplex
        - ussl
        - quest
        - sonora_quest
        - labcorp
        - bioreference
        - us_biotek
        - manual
        - sanocardio
        - ihd
        - nexus
        - my_uti
        - crl
      title: Labs
    ContinuousQueryDataEventPreferences:
      properties:
        enabled:
          type: boolean
          title: Enabled
          default: true
      type: object
      title: ContinuousQueryDataEventPreferences
    AggregateExpr-Output:
      properties:
        arg:
          anyOf:
            - $ref: '#/components/schemas/SleepColumnExpr'
            - $ref: '#/components/schemas/DerivedReadinessColumnExpr'
            - $ref: '#/components/schemas/ActivityColumnExpr'
            - $ref: '#/components/schemas/WorkoutColumnExpr'
            - $ref: '#/components/schemas/BodyColumnExpr'
            - $ref: '#/components/schemas/MealColumnExpr'
            - $ref: '#/components/schemas/MenstrualCycleColumnExpr'
            - $ref: '#/components/schemas/ProfileColumnExpr'
            - $ref: '#/components/schemas/SleepScoreValueMacroExpr'
            - $ref: '#/components/schemas/ChronotypeValueMacroExpr'
            - $ref: '#/components/schemas/AsleepAtValueMacroExpr'
            - $ref: '#/components/schemas/AwakeAtValueMacroExpr'
            - $ref: '#/components/schemas/AwakeningsValueMacroExpr'
            - $ref: '#/components/schemas/UnrecognizedValueMacroExpr'
            - $ref: '#/components/schemas/DiscreteTimeseriesExpr'
            - $ref: '#/components/schemas/IntervalTimeseriesExpr'
            - $ref: '#/components/schemas/InsulinInjectionTimeseriesExpr'
            - $ref: '#/components/schemas/BloodPressureTimeseriesExpr'
            - $ref: '#/components/schemas/TemperatureTimeseriesExpr'
            - $ref: '#/components/schemas/WorkoutDurationTimeseriesExpr'
            - $ref: '#/components/schemas/NoteTimeseriesExpr'
            - $ref: '#/components/schemas/IndexColumnExpr'
            - $ref: '#/components/schemas/ScalarOutputSubqueryExpr-Output'
          title: Arg
        func:
          type: string
          enum:
            - mean
            - min
            - max
            - sum
            - count
            - median
            - stddev
            - oldest
            - newest
          title: Func
      type: object
      required:
        - arg
        - func
      title: AggregateExpr
    ScalarOutputSubqueryExpr-Output:
      properties:
        select:
          anyOf:
            - $ref: '#/components/schemas/AggregateFieldExpr'
            - $ref: '#/components/schemas/Placeholder'
          title: Select
        from:
          anyOf:
            - $ref: '#/components/schemas/UnnestExpr'
            - $ref: '#/components/schemas/Placeholder'
          title: From
        where:
          anyOf:
            - type: string
            - type: 'null'
          title: Where
      type: object
      required:
        - select
        - from
      title: ScalarOutputSubqueryExpr
      description: A subquery that produces a single scalar value per row.
    AggregateFieldExpr:
      properties:
        func:
          type: string
          enum:
            - mean
            - min
            - max
            - sum
            - count
            - median
            - stddev
            - oldest
            - newest
          title: Func
        arg:
          anyOf:
            - $ref: '#/components/schemas/MCMenstrualFlowFieldExpr'
            - $ref: '#/components/schemas/MCCervicalMucusFieldExpr'
            - $ref: '#/components/schemas/MCIntermenstrualBleedingFieldExpr'
            - $ref: '#/components/schemas/MCContraceptiveFieldExpr'
            - $ref: '#/components/schemas/MCDetectedDeviationsFieldExpr'
            - $ref: '#/components/schemas/MCOvulationTestFieldExpr'
            - $ref: '#/components/schemas/MCHomePregnancyTestFieldExpr'
            - $ref: '#/components/schemas/MCHomeProgesteroneTestFieldExpr'
            - $ref: '#/components/schemas/MCSexualActivityFieldExpr'
            - $ref: '#/components/schemas/MCBasalBodyTemperatureFieldExpr'
            - $ref: '#/components/schemas/ElementFieldExpr'
            - type: 'null'
          title: Arg
      type: object
      required:
        - func
      title: AggregateFieldExpr
      description: >-
        Aggregate over unnested list elements, optionally targeting a struct
        field.


        When arg is None, the aggregate operates on the list elements directly

        (e.g., count-all, or mean/sum on a scalar numeric list).

        When arg is a FieldExpr, the struct field is extracted before
        aggregating.
    Placeholder:
      properties:
        placeholder:
          type: boolean
          const: true
          title: Placeholder
      type: object
      required:
        - placeholder
      title: Placeholder
    UnnestExpr:
      properties:
        unnest:
          anyOf:
            - $ref: '#/components/schemas/SleepColumnExpr'
            - $ref: '#/components/schemas/DerivedReadinessColumnExpr'
            - $ref: '#/components/schemas/ActivityColumnExpr'
            - $ref: '#/components/schemas/WorkoutColumnExpr'
            - $ref: '#/components/schemas/BodyColumnExpr'
            - $ref: '#/components/schemas/MealColumnExpr'
            - $ref: '#/components/schemas/MenstrualCycleColumnExpr'
            - $ref: '#/components/schemas/ProfileColumnExpr'
            - $ref: '#/components/schemas/SleepScoreValueMacroExpr'
            - $ref: '#/components/schemas/ChronotypeValueMacroExpr'
            - $ref: '#/components/schemas/AsleepAtValueMacroExpr'
            - $ref: '#/components/schemas/AwakeAtValueMacroExpr'
            - $ref: '#/components/schemas/AwakeningsValueMacroExpr'
            - $ref: '#/components/schemas/UnrecognizedValueMacroExpr'
            - $ref: '#/components/schemas/DiscreteTimeseriesExpr'
            - $ref: '#/components/schemas/IntervalTimeseriesExpr'
            - $ref: '#/components/schemas/InsulinInjectionTimeseriesExpr'
            - $ref: '#/components/schemas/BloodPressureTimeseriesExpr'
            - $ref: '#/components/schemas/TemperatureTimeseriesExpr'
            - $ref: '#/components/schemas/WorkoutDurationTimeseriesExpr'
            - $ref: '#/components/schemas/NoteTimeseriesExpr'
          title: Unnest
      type: object
      required:
        - unnest
      title: UnnestExpr
      description: 'FROM clause variant: unnest a list column into elements.'
    Period:
      properties:
        value:
          type: integer
          minimum: 1
          title: Value
          default: 1
        unit:
          type: string
          enum:
            - minute
            - hour
            - day
            - week
            - month
            - year
          title: Unit
      type: object
      required:
        - unit
      title: Period
    MCMenstrualFlowFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        menstrual_flow:
          type: string
          enum:
            - date
            - flow
          title: Menstrual Flow
      additionalProperties: false
      type: object
      required:
        - menstrual_flow
      title: MCMenstrualFlowFieldExpr
    MCCervicalMucusFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        cervical_mucus:
          type: string
          enum:
            - date
            - quality
          title: Cervical Mucus
      additionalProperties: false
      type: object
      required:
        - cervical_mucus
      title: MCCervicalMucusFieldExpr
    MCIntermenstrualBleedingFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        intermenstrual_bleeding:
          type: string
          const: date
          title: Intermenstrual Bleeding
      additionalProperties: false
      type: object
      required:
        - intermenstrual_bleeding
      title: MCIntermenstrualBleedingFieldExpr
    MCContraceptiveFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        contraceptive:
          type: string
          enum:
            - date
            - type
          title: Contraceptive
      additionalProperties: false
      type: object
      required:
        - contraceptive
      title: MCContraceptiveFieldExpr
    MCDetectedDeviationsFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        detected_deviations:
          type: string
          enum:
            - date
            - deviation
          title: Detected Deviations
      additionalProperties: false
      type: object
      required:
        - detected_deviations
      title: MCDetectedDeviationsFieldExpr
    MCOvulationTestFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        ovulation_test:
          type: string
          enum:
            - date
            - test_result
          title: Ovulation Test
      additionalProperties: false
      type: object
      required:
        - ovulation_test
      title: MCOvulationTestFieldExpr
    MCHomePregnancyTestFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        home_pregnancy_test:
          type: string
          enum:
            - date
            - test_result
          title: Home Pregnancy Test
      additionalProperties: false
      type: object
      required:
        - home_pregnancy_test
      title: MCHomePregnancyTestFieldExpr
    MCHomeProgesteroneTestFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        home_progesterone_test:
          type: string
          enum:
            - date
            - test_result
          title: Home Progesterone Test
      additionalProperties: false
      type: object
      required:
        - home_progesterone_test
      title: MCHomeProgesteroneTestFieldExpr
    MCSexualActivityFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        sexual_activity:
          type: string
          enum:
            - date
            - protection_used
          title: Sexual Activity
      additionalProperties: false
      type: object
      required:
        - sexual_activity
      title: MCSexualActivityFieldExpr
    MCBasalBodyTemperatureFieldExpr:
      properties:
        field_for:
          type: string
          const: menstrual_cycle
          title: Field For
          default: menstrual_cycle
        basal_body_temperature:
          type: string
          enum:
            - date
            - value
          title: Basal Body Temperature
      additionalProperties: false
      type: object
      required:
        - basal_body_temperature
      title: MCBasalBodyTemperatureFieldExpr
    ElementFieldExpr:
      properties:
        element:
          type: boolean
          const: true
          title: Element
      additionalProperties: false
      type: object
      required:
        - element
      title: ElementFieldExpr
      description: |-
        References the element itself in a scalar-element list subquery arg.

        Symmetric with the reserved ``element`` keyword in WHERE predicates.
        Only valid when the UNNEST source is a ``List[scalar]``.
  securitySchemes:
    ManagementKey:
      type: apiKey
      in: header
      name: X-Management-Key

````