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

# Fetch sensor data

> Query time-series sensor readings for one or more parameters. Supports time range filtering, aggregation intervals, and multi-parameter selection across devices.



## OpenAPI

````yaml post /sensor-data
openapi: 3.1.0
info:
  title: Ontoto API
  description: Ontoto backend API
  version: 1.0.0
servers:
  - url: https://api.beta.ontoto.com/v1
security:
  - ApiKeyAuth: []
paths:
  /sensor-data:
    post:
      summary: Fetch sensor data
      description: >-
        Query time-series sensor readings for one or more parameters. Supports
        time range filtering, aggregation intervals, and multi-parameter
        selection across devices.
      operationId: postSensor-data
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SensorDataPostRequest'
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SensorDataPostResponse'
        '400':
          description: Invalid request format
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrBadRequest'
        '401':
          description: Client must be authenticated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrUnauthorized'
        '403':
          description: Client does not have necessary permissions to access the resource
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrForbidden'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrNotFound'
        '409':
          description: Request could not be completed due to a uniqueness constraint
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrConflict'
        '422':
          description: >-
            The query exceeded the server time limit. Narrow the time range,
            reduce the number of parameters/devices, or apply aggregation, then
            retry.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrQueryTooExpensive'
        '500':
          description: Unexpected server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrInternalServerError'
components:
  schemas:
    SensorDataPostRequest:
      description: >-
        Request body for querying sensor data. The union of all the parameters
        is resolved.
      example:
        parameterUuids:
          - 00000000-0000-0000-0000-000000000000
        startDate: '2024-01-01T00:00:00.000Z'
        endDate: '2024-01-31T23:59:59.000Z'
        orderBy: asc
      type: object
      properties:
        parameterUuids:
          description: Array of parameter UUIDs
          type: array
          items:
            type: string
            format: uuid
        deviceSerialNumbers:
          description: Array of device serial numbers
          type: array
          items:
            type: string
        legacyDeviceIds:
          description: Array of legacy device IDs
          type: array
          items:
            type: integer
            minimum: -9007199254740991
            maximum: 9007199254740991
        sensorUuids:
          description: Array of sensor UUIDs
          type: array
          items:
            type: string
            format: uuid
        parameterPaths:
          description: Array of parameter paths to query specific data points
          type: array
          items:
            $ref: '#/components/schemas/SensorParameterPath'
        startDate:
          description: Start date in ISO 8601 format
          example: '2024-01-01T00:00:00.000Z'
          format: date-time
          type: string
        endDate:
          description: End date in ISO 8601 format
          example: '2024-01-31T23:59:59.000Z'
          format: date-time
          type: string
        orderBy:
          description: Ordering of data by timestamp
          example: asc
          default: asc
          type: string
          oneOf:
            - const: asc
              title: asc
              description: Oldest first
            - const: desc
              title: desc
              description: Newest first
        aggregation:
          description: Optional aggregation to apply to each parameter over a time interval
          type: object
          properties:
            function:
              description: Function to aggregate time series data
              example: avg
              type: string
              oneOf:
                - const: avg
                  title: avg
                  description: Average of values in each interval
                - const: min
                  title: min
                  description: Minimum value in each interval
                - const: max
                  title: max
                  description: Maximum value in each interval
                - const: sum
                  title: sum
                  description: Sum of all values in each interval
                - const: first
                  title: first
                  description: First value in each interval
                - const: last
                  title: last
                  description: Last value in each interval
            interval:
              description: Time interval to aggregate data over
              example: 1h
              type: string
              format: duration
            fill:
              description: How to fill gaps in aggregated data
              example: none
              type: string
              oneOf:
                - const: none
                  title: none
                  description: Leave gaps empty
                - const: previous
                  title: previous
                  description: Carry the previous interval's value forward into the gap
                - const: next
                  title: next
                  description: Use the next interval's value to fill the gap
                - const: 'null'
                  title: 'null'
                  description: Insert an explicit null value in the gap
            timezone:
              description: IANA timezone identifier for interval alignment
              example: Australia/Melbourne
              type: string
            startTime:
              description: >-
                Custom start time for interval alignment in HH:mm format (e.g.,
                '09:00' for 9am). Required when timezone is specified.
              example: '09:00'
              type: string
              pattern: ^([0-1]?[0-9]|2[0-3]):[0-5][0-9]$
            dayOfMonth:
              description: >-
                Day of month (1-31) for monthly interval alignment. Required
                when interval is monthly.
              example: 15
              type: integer
              minimum: 1
              maximum: 31
          required:
            - function
            - interval
        disableRounding:
          description: >-
            Ignore the parameter's display precision and return values without
            rounding
          type: boolean
        includeDeleted:
          description: Include soft-deleted sensor data in results
          type: boolean
      title: SensorDataPostRequest
    SensorDataPostResponse:
      description: Response body for querying sensor data
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/ScalarSensorDataItem'
      required:
        - items
      title: SensorDataPostResponse
    ErrBadRequest:
      example:
        message: Invalid request body
      type: object
      properties:
        message:
          description: Human readable message describing the issue
          type: string
      required:
        - message
      title: ErrBadRequest
    ErrUnauthorized:
      example:
        message: Authentication required
      type: object
      properties:
        message:
          description: Human readable message describing the issue
          type: string
      required:
        - message
      title: ErrUnauthorized
    ErrForbidden:
      example:
        message: You do not have permission to access this resource
      type: object
      properties:
        message:
          description: Human readable message describing the issue
          type: string
      required:
        - message
      title: ErrForbidden
    ErrNotFound:
      example:
        message: Resource not found
      type: object
      properties:
        message:
          description: Human readable message describing the issue
          type: string
      required:
        - message
      title: ErrNotFound
    ErrConflict:
      example:
        message: Duplicate entry
      type: object
      properties:
        message:
          description: Human readable message describing the issue
          type: string
      required:
        - message
      title: ErrConflict
    ErrQueryTooExpensive:
      example:
        message: >-
          Query exceeded the time limit. Narrow the time range, reduce the
          number of parameters/devices, or apply aggregation.
      type: object
      properties:
        message:
          description: Human readable message describing the issue
          type: string
      required:
        - message
      title: ErrQueryTooExpensive
    ErrInternalServerError:
      example:
        message: Internal server error
      type: object
      properties:
        message:
          description: Human readable message describing the issue
          type: string
      required:
        - message
      title: ErrInternalServerError
    SensorParameterPath:
      description: Path to a specific parameter on a device
      example:
        deviceSerialNumber: '1234567890'
        sensorName: VibratingWire_CH1
        parameterName: Frequency_CH1
      type: object
      properties:
        deviceSerialNumber:
          description: Device serial number
          type: string
        sensorName:
          description: Unique name for the sensor on the device
          type: string
        parameterName:
          description: Unique name for the parameter on the sensor
          type: string
      required:
        - deviceSerialNumber
        - sensorName
        - parameterName
      title: SensorParameterPath
    ScalarSensorDataItem:
      description: Sensor data for a singular parameter
      type: object
      properties:
        deviceSerialNumber:
          description: Device serial number
          type: string
        deviceAlias:
          description: Device alias
          anyOf:
            - type: string
            - type: 'null'
        legacyDeviceId:
          description: Legacy device ID, if available
          anyOf:
            - type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
            - type: 'null'
        sensorUuid:
          description: Sensor UUID
          anyOf:
            - type: string
              format: uuid
            - type: 'null'
        sensorAlias:
          description: Sensor alias
          anyOf:
            - type: string
            - type: 'null'
        channelIndex:
          description: >-
            Zero-indexed sensor channel, the order the sensor is read on the
            device
          anyOf:
            - type: number
            - type: 'null'
        sensorStatus:
          $ref: '#/components/schemas/SensorStatus'
        parameterUuid:
          description: Parameter UUID
          type: string
          format: uuid
        parameterName:
          description: Parameter name
          type: string
        parameterAlias:
          description: Parameter alias
          type: string
        parameterSourceType:
          description: Origin of a parameter's data
          type: string
          oneOf:
            - const: derived
              title: derived
              description: Parameter computed from a formula or aggregation
            - const: raw
              title: raw
              description: Parameter measured directly by the device
            - const: imported
              title: imported
              description: Parameter ingested from an external (third party) source
            - const: weather_forecast
              title: weather_forecast
              description: Parameter populated from a weather forecast provider
            - const: gnss
              title: gnss
              description: Parameter produced by GNSS post-processing
            - const: gnss_field
              title: gnss_field
              description: Individual GNSS solution field (e.g. lat, lon, height)
        parameterStatus:
          description: Overall health status of a sensor parameter
          type: string
          oneOf:
            - const: ok
              title: ok
              description: No issues
            - const: data_fault
              title: data_fault
              description: >-
                Latest data points are faulty (null, out-of-range, or evaluation
                error)
            - const: config_error
              title: config_error
              description: Parameter configuration is invalid and cannot be evaluated
        displayPrecision:
          description: Rounding applied to parameter data, if any
          anyOf:
            - type: number
            - type: 'null'
        unit:
          description: Unit of parameter values (UCUM code)
          anyOf:
            - type: string
            - type: 'null'
        data:
          description: Array of timestamped sensor data
          type: array
          items:
            type: object
            properties:
              timestamp:
                description: ISO 8601 formatted timestamp
                type: string
                format: date-time
              value:
                description: Sensor parameter value
                anyOf:
                  - type: number
                  - type: 'null'
            required:
              - timestamp
              - value
      required:
        - deviceSerialNumber
        - deviceAlias
        - legacyDeviceId
        - sensorUuid
        - sensorAlias
        - channelIndex
        - sensorStatus
        - parameterUuid
        - parameterName
        - parameterAlias
        - parameterSourceType
        - parameterStatus
        - displayPrecision
        - unit
        - data
      title: ScalarSensorDataItem
    SensorStatus:
      description: >-
        Overall status dynamically derived from parameter errors. View details
        in the errors array.
      type: string
      oneOf:
        - const: ok
          title: ok
          description: All parameters are healthy
        - const: error
          title: error
          description: One or more parameters are in an error state
        - const: warning
          title: warning
          description: Sensor is operational but at least one parameter is faulty
        - const: unknown
          title: unknown
          description: Health cannot be determined (e.g. no data received yet)
      title: SensorStatus
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````