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

# List usage meters for event schema

> Get a list of usage meters associated with an event schema

export const ListAPIInfo = ({info: {query_fields, allowed_combinations, search_fields, sort_fields, default_sort}, show_filter_combinations}) => {
  return <AccordionGroup>
    {query_fields != null && query_fields.length > 0 ? <Accordion title="Query Parameters">
      {query_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
    </Accordion> : ''}

    {allowed_combinations != null && allowed_combinations.length > 0 ? <Accordion title="Filterable Fields">
      {[...new Set(allowed_combinations.flat())].map(field => <ParamField key={field} query={field} type="string" />)}
      {show_filter_combinations ? <>
        <h3 style={{
    marginTop: "0em"
  }}>Allowed filter combinations</h3>
        <ul>
          {allowed_combinations.map(comb => <li key="a">
              {comb.map((e, i) => <><code>{e}</code>{i != comb.length - 1 ? ", " : ""}</>)}
            </li>)}
        </ul>
        </> : ''}
    </Accordion> : ''}

    {search_fields != null && search_fields.length > 0 ? <Accordion title="Searchable Fields">
      Fields that can be searched on using <code>_search</code> query param
      {search_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
    </Accordion> : ''}

    {sort_fields != null && sort_fields.length > 0 ? <Accordion title="Sortable Fields">
      Fields with which the list response can be sorted using <code>_sort</code> query param
      {sort_fields.map(field => <ParamField key={field} query={field.name} type={field.type}>
            {field.description}
          </ParamField>)}
      {default_sort ? <Note>
            Default sort order:<code>{Object.entries(default_sort).map(e => e[0] + " " + e[1]).join(', ')}</code>
          </Note> : ''}
    </Accordion> : ''}

      
  </AccordionGroup>;
};

export const listUsageMeterQueryFields = {
  query_fields: [{
    name: "aggregation",
    type: "string",
    description: "Aggregation type for usage meters"
  }, {
    name: "status",
    type: "enum",
    description: "Status of the usage meter (`ACTIVE`, `ARCHIVED`)"
  }, {
    name: "id",
    type: "string",
    description: "Unique identifier of the usage meter"
  }],
  allowed_combinations: [["aggregation", "status"], ["status"], ["id"]],
  search_fields: [{
    name: "id",
    type: "string"
  }, {
    name: "name",
    type: "string"
  }, {
    name: "billable_name",
    type: "string"
  }],
  sort_fields: [{
    name: "updated_at",
    type: "string",
    description: ""
  }],
  default_sort: {
    "updated_at": "DESC"
  }
};

<ListAPIInfo info={listUsageMeterQueryFields} show_filter_combinations />


## OpenAPI

````yaml get /usage_meters
openapi: 3.0.3
info:
  version: '1.0'
  title: Togai Apis
  contact:
    email: engg@togai.com
  license:
    name: Apache 2.0
    url: http://www.apache.org/licenses/LICENSE-2.0.html
  description: APIs for Togai App
servers:
  - description: Api endpoint
    url: https://api.togai.com/
  - description: Sandbox api endpoint
    url: https://sandbox-api.togai.com/
security:
  - bearerAuth: []
tags:
  - name: Customers
    description: Customer level calls
  - name: Accounts
    description: Account level calls
  - name: Event Schemas
    description: Event Schema level calls
  - name: Usage Meters
    description: Usage Meter level calls
  - name: Price Plans
    description: (DEPRECATED) Price Plan level calls
  - name: PricePlanV2
    description: Price Plan V2 level calls
  - name: Schedules
    description: Account Schedule level calls
  - name: Pricing Rules
    description: Pricing Rules level calls
  - name: Settings
    description: Settings
  - name: Price Experimentation
    description: Price Experimentation apis
  - name: InvoiceGroups
    description: Invoice Group level calls
  - name: Organization
    description: Organization level calls
  - name: FileStorage
    description: File Storage level calls
  - name: Aliases
    description: Alias level calls
  - name: Reports
    description: Report level calls
  - name: ReportTemplates
    description: Report Template level calls
  - name: Customer Portal
    description: Portal level calls
  - name: Alerts
    description: Alert level calls
  - name: Event Management
    description: APIs for getting events ingested in Togai
    externalDocs:
      description: docs
      url: https://togai.com/docs/billing/events
  - name: Metrics
    description: APIs for getting Togai metrics
    externalDocs:
      description: docs
      url: https://togai.com/docs/metrics
  - name: Licenses
    description: APIs for getting or updating license records in Togai
  - name: Entitlements
    description: APIs related to entitlements
  - name: Invoices
    description: Invoices API
  - name: Credits
    description: Credits API
  - name: Wallet
    description: Wallet API
  - name: InvoiceTemplates
    description: InvoiceTemplates API
  - name: InvoiceSequence
    description: InvoiceSequence API
  - name: Payments
    description: Payments API
  - name: Authentication
    description: Authentication API
externalDocs:
  description: Find out more about Togai
  url: https://docs.togai.com/docs
paths:
  /usage_meters:
    get:
      tags:
        - Usage Meters
      summary: List usage meters for event schema
      description: Get a list of usage meters associated with an event schema
      operationId: getUsageMetersForEventSchema
      parameters:
        - name: status
          description: |
            Filter by status
          in: query
          required: false
          schema:
            type: string
            enum:
              - ACTIVE
              - INACTIVE
        - name: aggregations
          description: |
            Filter by aggregations
          in: query
          required: false
          schema:
            type: string
            enum:
              - COUNT
              - SUM
        - $ref: '#/components/parameters/next_token'
        - $ref: '#/components/parameters/page_size'
      responses:
        '200':
          $ref: '#/components/responses/UsageMeterPaginatedResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '403':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '429':
          $ref: '#/components/responses/ErrorResponse'
        default:
          $ref: '#/components/responses/ErrorResponse'
components:
  parameters:
    next_token:
      in: query
      name: nextToken
      required: false
      schema:
        type: string
        example: >-
          eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ==
    page_size:
      in: query
      name: pageSize
      required: false
      schema:
        type: number
        example: 10
  responses:
    UsageMeterPaginatedResponse:
      description: Response for list usage_meters request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/UsageMeterPaginatedResponse'
          examples:
            UsageMeterPaginatedResponse:
              $ref: '#/components/examples/UsageMeterPaginatedResponse'
    ErrorResponse:
      description: Error response
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ErrorResponse'
          examples:
            ErrorResponse:
              summary: Error message
              value:
                message: <Reason message>
  schemas:
    UsageMeterPaginatedResponse:
      type: object
      additionalProperties: false
      properties:
        data:
          type: array
          items:
            $ref: '#/components/schemas/UsageMeter'
        nextToken:
          type: string
        context:
          $ref: '#/components/schemas/PaginationOptions'
    ErrorResponse:
      type: object
      additionalProperties: false
      required:
        - message
      properties:
        message:
          type: string
          description: error description
          maxLength: 500
    UsageMeter:
      description: Structure of usage meter
      type: object
      additionalProperties: false
      required:
        - id
        - name
        - displayName
        - type
        - aggregation
      properties:
        id:
          description: Identifier of the usage meter
          type: string
          maxLength: 20
        name:
          description: Name of the usage meter
          type: string
          maxLength: 50
          pattern: ^[\sa-zA-Z0-9_-]*$
          example: rides-usage
        billableName:
          description: >-
            Billable name of addon. Billable name takes precedence over name to
            display in invoice.
          type: string
          maxLength: 255
          example: Rides Usage
        displayName:
          description: >
            Display name of usage meter. This is an auto-generated field which
            contains billableName of usage meter.

            If billableName is not provided, name will be used as display name.
          type: string
          maxLength: 255
        description:
          type: string
          maxLength: 255
          example: Meter to track cab rides
        filters:
          type: array
          items:
            $ref: '#/components/schemas/UsageMeterFilterEntry'
        type:
          description: Type of usage meter
          type: string
          enum:
            - COUNTER
          example: COUNTER
        status:
          description: Status of usage meter
          type: string
          enum:
            - DRAFT
            - ACTIVE
            - INACTIVE
            - ARCHIVED
          example: DRAFT
        aggregation:
          $ref: '#/components/schemas/UsageMeterAggregation'
        computations:
          type: array
          minItems: 0
          maxItems: 1
          items:
            $ref: '#/components/schemas/Computation'
        eventSchema:
          $ref: '#/components/schemas/EventSchema'
        createdAt:
          type: string
          format: date-time
        lastActivatedAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    PaginationOptions:
      type: object
      additionalProperties: false
      properties:
        pageSize:
          type: integer
        sortOrder:
          type: string
          enum:
            - ASC
            - DESC
    UsageMeterFilterEntry:
      description: Filter entry with field and value
      type: object
      required:
        - field
        - value
      properties:
        field:
          type: string
        value:
          type: string
    UsageMeterAggregation:
      description: >
        Aggregation to be applied on usage meter result

        * COUNT - Counts number of events matching the usage meter

        * SUM - Sums up results of computation of all events matching usage
        meter
      type: string
      enum:
        - COUNT
        - SUM
    Computation:
      type: object
      required:
        - computation
        - order
      properties:
        id:
          description: Optional identifier describing the matcher and computation pair
          type: string
          maxLength: 50
        matcher:
          description: >
            Condition to be applied on event. Upon matching it the corresponding
            computation will be considered for usage_meter unit calculation. The
            result of the matcher needs to be
            [truthy](https://jsonlogic.com/truthy.html) in order to be
            considered as a match.
          type: string
          maxLength: 1500
          example: |
            {
              "and": [
                {"in": [{"var": "dimension.city"}, "chennai", "mumbai"]},
                "or": [
                  {">": [{"var": "attribute.distance"}, 100]},
                  {"<": [{"var": "attribute.distance"}, 20]}
                ]
              ]
            }
        computation:
          description: >
            Computation to be applied on an event if it matches the matcher. In
            case of a COUNT aggregation type, computation should be passed as
            '1'
          type: string
          maxLength: 500
          example:
            '*':
              - var: attributes.distance
              - 0.4
        order:
          description: The order in which multiple matched computations will get evaluated
          type: integer
    EventSchema:
      description: Structure of an event schema
      type: object
      additionalProperties: false
      required:
        - name
        - version
      properties:
        name:
          description: Name of the event. Must be unique for an organization.
          type: string
          maxLength: 50
          pattern: ^[\sa-zA-Z0-9_-]*$
        description:
          description: Description of the event
          type: string
          maxLength: 255
        version:
          description: Version of event schema
          type: integer
          format: int32
          minimum: 1
          example: 1
        status:
          description: |
            Status of event schema
            * DRAFT - Schema is in draft state 
            * ACTIVE - Schema is currently active 
            * INACTIVE - Schema is currently inactive
            * ARCHIVED - Older version of event schema
          type: string
          enum:
            - DRAFT
            - ACTIVE
            - INACTIVE
            - ARCHIVED
          example: DRAFT
        attributes:
          type: array
          maxItems: 50
          items:
            $ref: '#/components/schemas/EventAttributeSchema'
          uniqueItems: true
        dimensions:
          type: array
          maxItems: 50
          items:
            $ref: '#/components/schemas/DimensionsSchema'
          uniqueItems: true
        filterFields:
          type: array
          uniqueItems: true
          items:
            type: string
        featureDetails:
          $ref: '#/components/schemas/FeatureDetails'
        enrichments:
          $ref: '#/components/schemas/Enrichments'
        eventIdTemplate:
          description: Template used to generate event id based on event payload
          type: string
        eventLevelRevenue:
          type: boolean
        createdAt:
          type: string
          format: date-time
        updatedAt:
          type: string
          format: date-time
    EventAttributeSchema:
      description: Structure of an event attribute
      type: object
      additionalProperties: false
      required:
        - name
      properties:
        name:
          description: Name of the event attribute.
          type: string
          maxLength: 50
          pattern: ^[\sa-zA-Z0-9_-]*$
          example: distance
        defaultUnit:
          description: Unit for the attribute
          type: string
          maxLength: 10
          example: kms
    DimensionsSchema:
      description: Structure of dimensions
      type: object
      additionalProperties: false
      required:
        - name
      properties:
        name:
          description: Name of the event dimension
          type: string
          maxLength: 50
          pattern: ^[\sa-zA-Z0-9_-]*$
          example: city
    FeatureDetails:
      description: details of feature associated with event schema with attribute name
      type: object
      additionalProperties: false
      required:
        - featureId
        - attributeName
      properties:
        featureId:
          type: string
        attributeName:
          type: string
    Enrichments:
      type: object
      additionalProperties: false
      required:
        - fields
      properties:
        dependencies:
          type: array
          items:
            $ref: '#/components/schemas/Dependency'
        fields:
          type: array
          items:
            $ref: '#/components/schemas/Field'
    Dependency:
      type: object
      additionalProperties: false
      required:
        - type
        - key
        - name
      properties:
        type:
          type: string
          enum:
            - SETTING
        key:
          type: string
        name:
          type: string
    Field:
      type: object
      additionalProperties: false
      required:
        - name
        - type
        - enrichmentType
        - value
        - order
      properties:
        name:
          type: string
        type:
          type: string
          enum:
            - ATTRIBUTE
            - DIMENSION
        enrichmentType:
          type: string
          enum:
            - VALUE
            - JSON_LOGIC
            - JSON_LOGIC_FROM_DEPENDENCY
        value:
          type: string
        order:
          type: integer
          format: int32
  examples:
    UsageMeterPaginatedResponse:
      value:
        data:
          - id: 01BX5ZZKBKACTAV9WEVG
            name: Rides
            displayName: Rides Usage
            description: Cab rides
            type: COUNTER
            aggregation: COUNT
            status: DRAFT
            computations:
              - matcher: |
                  {
                    "and": [
                      {"in": [{"var": "dimension.city"}, "chennai", "mumbai"]},
                      "or": [
                        {">": [{"var": "attribute.distance"}, 100]},
                        {"<": [{"var": "attribute.distance"}, 20]}
                      ]
                    ]
                  }
                order: 1
                computation: '1'
        nextToken: >-
          eyJsYXN0SXRlbUlkIjogInN0cmluZyIsICJwYWdlU2l6ZSI6IDEwMCwgInNvcnRPcmRlciI6ICJhc2MifQ==
        context:
          pageSize: 10
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: Bearer <credential>

````