> ## 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.

# Query revenue analytics

> Aggregates revenue_facts by the requested dimensions at day/period/total granularity. allocation_policy places whole-period charges on their booked day (billed) or spreads them across the period (amortized); include_adjustments breaks out true-up/overage/revert amounts as labeled rows. Requires the tenant's revenue analytics setting.



## OpenAPI

````yaml /api-reference/openapi.json post /analytics/revenue
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:
  /analytics/revenue:
    post:
      tags:
        - Analytics
      summary: Query revenue analytics
      description: >-
        Aggregates revenue_facts by the requested dimensions at day/period/total
        granularity. allocation_policy places whole-period charges on their
        booked day (billed) or spreads them across the period (amortized);
        include_adjustments breaks out true-up/overage/revert amounts as labeled
        rows. Requires the tenant's revenue analytics setting.
      operationId: getRevenueAnalytics
      requestBody:
        description: Revenue analytics request
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/RevenueAnalyticsRequest'
        required: true
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RevenueAnalyticsResponse'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/errors.ErrorResponse'
        '403':
          description: Revenue analytics not enabled
          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:
    RevenueAnalyticsRequest:
      required:
        - start_time
      type: object
      properties:
        allocation_policy:
          $ref: '#/components/schemas/types.RevenueAllocationPolicy'
        currency:
          type: string
        customer_ids:
          type: array
          description: Filters restrict the rows before aggregation.
          items:
            type: string
        end_time:
          type: string
          format: date-time
        granularity:
          $ref: '#/components/schemas/types.RevenueGranularity'
        group_by:
          type: array
          description: >-
            GroupBy dimensions: revenue_source, source (the event source
            recorded in

            meter_usage; requires customer_ids or subscription_ids),
            customer_id,

            subscription_id, price_id, meter_id, currency. revenue_source is
            always

            applied — every row says what kind of revenue it is — and requested

            dimensions are added on top.
          items:
            type: string
        include_adjustments:
          type: boolean
          description: |-
            IncludeAdjustments breaks the non-obvious components — commitment
            true-ups, overage and revert (contra) rows — out as their own rows,
            each labeled with its kind in adjustment_type. Off, they fold into
            their parent buckets (true-up/overage into usage, reverts into their
            own source) so visible rows read as plain usage/fixed. Totals are
            identical either way.
        meter_ids:
          type: array
          items:
            type: string
        price_ids:
          type: array
          items:
            type: string
        start_time:
          type: string
          description: >-
            StartTime/EndTime bound the day range (inclusive days derived in
            UTC).

            EndTime is optional and defaults to now.
          format: date-time
        status:
          $ref: '#/components/schemas/types.FactStatus'
        subscription_ids:
          type: array
          items:
            type: string
    RevenueAnalyticsResponse:
      type: object
      properties:
        contains_allocated:
          type: boolean
          description: >-
            ContainsAllocated is true when any bucket includes whole-period
            amounts

            spread across days (amortized) or booked on a single day (billed) —

            i.e. the day view carries period-shaped charges, not only true daily

            accruals.
        query:
          $ref: '#/components/schemas/RevenueAnalyticsRequest'
        rows:
          type: array
          items:
            $ref: '#/components/schemas/RevenueAnalyticsRow'
    errors.ErrorResponse:
      type: object
      properties:
        code:
          $ref: '#/components/schemas/errors.ErrorCode'
        http_status_code:
          type: integer
        message:
          type: string
      x-speakeasy-name-override: ErrorResponse
    types.RevenueAllocationPolicy:
      type: string
      enum:
        - billed
        - amortized
      x-enum-varnames:
        - RevenueAllocationBilled
        - RevenueAllocationAmortized
      x-speakeasy-name-override: RevenueAllocationPolicy
    types.RevenueGranularity:
      type: string
      enum:
        - day
        - period
        - total
      x-enum-varnames:
        - RevenueGranularityDay
        - RevenueGranularityPeriod
        - RevenueGranularityTotal
      x-speakeasy-name-override: RevenueGranularity
    types.FactStatus:
      type: string
      enum:
        - PROVISIONAL
        - FINAL
      x-enum-varnames:
        - FactProvisional
        - FactFinal
      x-speakeasy-name-override: FactStatus
    RevenueAnalyticsRow:
      type: object
      properties:
        adjustment_type:
          type: string
          description: |-
            AdjustmentType labels rows broken out by include_adjustments:
            "commitment_trueup", "overage" or "revert". Empty for plain rows.
        billable_qty:
          type: number
        day:
          type: string
          description: Day is set for day granularity; PeriodStart/PeriodEnd for period.
        entitlement_amount:
          type: number
        entitlement_qty:
          type: number
        group:
          type: object
          additionalProperties:
            type: string
          description: >-
            Group holds the requested dimensions and their values for this
            bucket.
        invoice_discount:
          type: number
        line_discount:
          type: number
        net_amount:
          type: number
        period_end:
          type: string
          format: date-time
        period_start:
          type: string
          format: date-time
        status:
          $ref: '#/components/schemas/types.FactStatus'
        tier_delta:
          type: number
        usage_at_list_rate:
          type: number
    errors.ErrorCode:
      type: string
      enum:
        - http_client_error
        - system_error
        - internal_error
        - not_found
        - already_exists
        - version_conflict
        - validation_error
        - invalid_operation
        - permission_denied
        - database_error
        - service_unavailable
        - too_many_requests
        - not_implemented
      x-enum-varnames:
        - ErrCodeHTTPClient
        - ErrCodeSystemError
        - ErrCodeInternalError
        - ErrCodeNotFound
        - ErrCodeAlreadyExists
        - ErrCodeVersionConflict
        - ErrCodeValidation
        - ErrCodeInvalidOperation
        - ErrCodePermissionDenied
        - ErrCodeDatabase
        - ErrCodeServiceUnavailable
        - ErrCodeTooManyRequests
        - ErrCodeNotImplemented
      x-speakeasy-name-override: ErrorCode
  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

````