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

# Calculate usage metric for customer and timeframe

> Calculate usage metric for customer and timeframe



## OpenAPI

````yaml usage.latest.product.live GET /usage-metrics/{usageMetricId}/calculate
openapi: 3.0.0
info:
  title: Usage
  description: Manage usage events and metrics
  version: '0.1'
servers:
  - url: https://dev.seqhq.io/api
    description: DEV
  - url: https://sandbox.sequencehq.com/api
    description: SANDBOX
  - url: https://eu.sequencehq.com/api
    description: PRODUCTION
security: []
tags: []
paths:
  /usage-metrics/{usageMetricId}/calculate:
    servers: []
    parameters: []
    get:
      tags:
        - Usage Metrics
      summary: Calculate usage metric for customer and timeframe
      description: Calculate usage metric for customer and timeframe
      operationId: getUsageMetricsByUsageMetricIdCalculate
      parameters:
        - name: usageMetricId
          in: path
          description: Usage Metric ID
          required: true
          schema:
            type: string
        - name: Authorization
          in: header
          description: >-
            Your [API credentials](/reference/authentication). Eg. `Basic
            {credentials}`.
          required: true
          schema:
            type: string
        - name: customerAliases
          in: query
          description: Customer Aliases / internal IDs
          required: true
          schema:
            type: string
        - name: periodStart
          in: query
          description: Billing period start
          required: true
          schema:
            type: string
        - name: periodEnd
          in: query
          description: Billing period end (inclusive)
          required: true
          schema:
            type: string
        - name: customParameters
          in: query
          description: Custom parameter values
          required: false
          schema:
            type: string
        - name: Sequence-Version
          in: header
          description: Use this header to select an API version
          required: false
          schema:
            type: string
            enum:
              - '2024-07-30'
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UsageMetricCalculationResponse'
                example:
                  name: total_messages_sent
                  metricType: GROUPED
                  eventType: message_sent
                  aggregationType: SUM
                  eventCount: 5
                  value: 150.035
                  unit: bytes
                  minEventId: 0183d0f1-6b5a-74d4-9129-1f4b90191666
                  maxEventId: 0183ea03-aca0-7019-b80d-6aacce344e92
              examples:
                UsageMetricCalculationResponse:
                  summary: ''
                  value:
                    name: total_messages_sent
                    metricType: GROUPED
                    eventType: message_sent
                    aggregationType: SUM
                    eventCount: 5
                    value: 150.035
                    unit: bytes
                    minEventId: 0183d0f1-6b5a-74d4-9129-1f4b90191666
                    maxEventId: 0183ea03-aca0-7019-b80d-6aacce344e92
        '400':
          description: Bad Request
          content: {}
        '401':
          description: Unauthorized
          content: {}
        '500':
          description: Internal Server Error
          content: {}
components:
  schemas:
    UsageMetricCalculationResponse:
      required:
        - aggregationType
        - eventCount
        - eventType
        - metricType
        - name
        - value
      type: object
      example:
        name: total_messages_sent
        metricType: GROUPED
        eventType: message_sent
        aggregationType: SUM
        eventCount: 5
        value: 150.035
        unit: bytes
        minEventId: 0183d0f1-6b5a-74d4-9129-1f4b90191666
        maxEventId: 0183ea03-aca0-7019-b80d-6aacce344e92
      properties:
        name:
          type: string
          example: total_messages_sent
        metricType:
          $ref: '#/components/schemas/MetricType'
        eventType:
          type: string
          example: message_sent
        aggregationType:
          $ref: '#/components/schemas/AggregationType'
        eventCount:
          type: integer
          example: 5
        value:
          type: number
          example: 150.035
        unit:
          type: string
          example: bytes
        minEventId:
          type: string
          example: 0183d0f1-6b5a-74d4-9129-1f4b90191666
        maxEventId:
          type: string
          example: 0183ea03-aca0-7019-b80d-6aacce344e92
    MetricType:
      type: string
      example: GROUPED
      enum:
        - SIMPLE
        - GROUPED
    AggregationType:
      type: string
      example: COUNT
      enum:
        - COUNT
        - UNIQUE
        - SUM
        - CUSTOM

````