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

# Get meter usage analytics

> Query aggregated usage from meter_usage table for multiple meters



## OpenAPI

````yaml /api-reference/openapi.json post /meter-usage/analytics
openapi: 3.0.1
info:
  title: Flexprice API
  description: Flexprice API Service
  contact:
    name: API Support
  license:
    name: AGPL-3.0
    url: https://www.gnu.org/licenses/agpl-3.0.html
  version: '1.0'
servers:
  - url: https://us.api.flexprice.io/v1
    description: US Region
  - url: https://api.cloud.flexprice.io/v1
    description: India Region
security: []
paths:
  /meter-usage/analytics:
    post:
      tags:
        - MeterUsage
      summary: Get meter usage analytics
      description: Query aggregated usage from meter_usage table for multiple meters
      operationId: getMeterUsageAnalytics
      requestBody:
        description: Analytics parameters
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/MeterUsageAnalyticsRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MeterUsageAnalyticsResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
      security:
        - ApiKeyAuth: []
components:
  schemas:
    MeterUsageAnalyticsRequest:
      required:
        - aggregation_type
        - end_time
        - external_customer_id
        - meter_ids
        - start_time
      type: object
      properties:
        aggregation_type:
          $ref: '#/components/schemas/types.AggregationType'
        billing_anchor:
          type: string
          format: date-time
        end_time:
          type: string
          example: '2024-02-01T00:00:00Z'
          format: date-time
        external_customer_id:
          type: string
          example: cust_123
        meter_ids:
          minItems: 1
          type: array
          example:
            - mtr_abc
            - mtr_def
          items:
            type: string
        start_time:
          type: string
          example: '2024-01-01T00:00:00Z'
          format: date-time
        window_size:
          $ref: '#/components/schemas/types.WindowSize'
    MeterUsageAnalyticsResponse:
      type: object
      properties:
        items:
          type: array
          items:
            $ref: '#/components/schemas/MeterUsageQueryResponse'
    errors.ErrorResponse:
      type: object
      properties:
        code:
          type: string
          enum:
            - not_found
            - already_exists
            - version_conflict
            - validation_error
            - invalid_operation
            - permission_denied
            - http_client_error
            - database_error
            - system_error
            - internal_error
            - service_unavailable
        details:
          type: object
          additionalProperties:
            type: object
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    types.AggregationType:
      type: string
      enum:
        - COUNT
        - SUM
        - AVG
        - COUNT_UNIQUE
        - LATEST
        - SUM_WITH_MULTIPLIER
        - MAX
        - WEIGHTED_SUM
      x-enum-comments:
        AggregationSumWithMultiplier: Sum with a multiplier - [sum(value) * multiplier]
      x-enum-varnames:
        - AggregationCount
        - AggregationSum
        - AggregationAvg
        - AggregationCountUnique
        - AggregationLatest
        - AggregationSumWithMultiplier
        - AggregationMax
        - AggregationWeightedSum
      x-speakeasy-name-override: AggregationType
    types.WindowSize:
      type: string
      enum:
        - MINUTE
        - 15MIN
        - 30MIN
        - HOUR
        - 3HOUR
        - 6HOUR
        - 12HOUR
        - DAY
        - WEEK
        - MONTH
        - MONTH
      x-enum-varnames:
        - WindowSizeMinute
        - WindowSize15Min
        - WindowSize30Min
        - WindowSizeHour
        - WindowSize3Hour
        - WindowSize6Hour
        - WindowSize12Hour
        - WindowSizeDay
        - WindowSizeWeek
        - WindowSizeMonth
        - DefaultWindowSize
      x-speakeasy-name-override: WindowSize
    MeterUsageQueryResponse:
      type: object
      properties:
        aggregation_type:
          $ref: '#/components/schemas/types.AggregationType'
        event_count:
          type: integer
          example: 42
        meter_id:
          type: string
          example: mtr_abc
        points:
          type: array
          items:
            $ref: '#/components/schemas/MeterUsagePoint'
        total_value:
          type: string
          example: '1234.5678'
    MeterUsagePoint:
      type: object
      properties:
        event_count:
          type: integer
          example: 10
        timestamp:
          type: string
          example: '2024-01-01T00:00:00Z'
        value:
          type: string
          example: '100.0000'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      description: Enter your API key in the format *x-api-key &lt;api-key&gt;**
      name: x-api-key
      in: header

````