---
title: "Get Togai Metrics"
method: POST
path: "/metrics"
tags: ["Metrics"]
---

# Get Togai Metrics

`POST /metrics`

Togai Metrics API allows you to fetch different metrics from Events, Usage Meters and PricePlans with multiple queryable options.
A single request can query up to five metrics. 
Single response can contain a maximum of 300 data points.

## Request body

- GetMetricsRequest — Request to get metrics from togai
  - `startTime` string, date-time, required — Start date time of the query (inclusive)
  - `endTime` string, date-time, required — End date time of the query (exclusive)
  - `metricQueries` MetricQuery[], required
    - `id` string, required — Mandatory for all request. User defined ID for identifying the request for your internal reference
    - `name` 'EVENTS' | 'USAGE' | 'METER_USAGE' | 'NAMED_LICENSE_USAGE' | 'REVENUE' | 'USAGE_FOR_CYCLE' | 'REVENUE_FOR_CYCLE', required — Define the metric you would like to get - allowed options are EVENTS - Aggregation of raw events, USAGE - Default to METER_USAGE. To be deprecated soon, METER_USAGE - Aggregated usage value from Usage meters, NAMED_LICENSE_USAGE - Aggregated usage value from Named Licenses, REVENUE - Aggregated revenue value from Pricing Plans USAGE_FOR_CYCLE - Usage in pricing cycle REVENUE_FOR_CYCLE - Revenue in pricing cycle
    - `aggregationPeriod` 'HOUR' | 'DAY' | 'WEEK' | 'MONTH', required — Set the aggregation period. Allowed periods are HOUR, DAY, WEEK, MONTH
    - `groupBy` string — Group your metric with a groupBy field. Allowed fields are ACCOUNT_ID EVENT_STATUS SCHEMA_NAME USAGE_METER_ID [Use BILLABLE_ID as this will be deprecated soon...] BILLABLE_ID RAW_EVENT_STATUS Please refer the table above for the list of combinations allowed in the groupBy
    - `configs` unknown
    - `filters` object[] — Filter on specific fields. Refer possible fieldNames and fieldValues from the table above.
      - `fieldName` string, required
      - `fieldValues` string[], required

## Response `200`

Success response

- GetMetricsResponse — Response to GetMetrics Request
  - `results` MetricQueryResponse[], required
    - `id` string, required
    - `name` 'EVENTS' | 'USAGE' | 'METER_USAGE' | 'NAMED_LICENSE_USAGE' | 'REVENUE' | 'USAGE_FOR_CYCLE' | 'REVENUE_FOR_CYCLE', required — Define the metric you would like to get - allowed options are EVENTS - Aggregation of raw events, USAGE - Default to METER_USAGE. To be deprecated soon, METER_USAGE - Aggregated usage value from Usage meters, NAMED_LICENSE_USAGE - Aggregated usage value from Named Licenses, REVENUE - Aggregated revenue value from Pricing Plans USAGE_FOR_CYCLE - Usage in pricing cycle REVENUE_FOR_CYCLE - Revenue in pricing cycle
    - `data` MetricDataPoints[], required
      - `groupedBy` object
        - `fieldName` string, required
        - `fieldValue` string, required
      - `timestamps` string[], required
      - `metricValues` number[], required

## Other responses

- `400` — Bad request. Please check the response message for failure details.
- `401` — Credential is not valid. Please check the response message for failure details.
- `403` — Credential does not have access to get metrics.
- `429` — Request throttled. Please check the response message on the failure details.
- `default` — Error response

---

[API](https://skmtc.net/togaihq/apis/togai-apis.md) · [All operations](https://skmtc.net/togaihq/apis/togai-apis/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/togaihq/togai-apis/revisions/442f5d8f4aa0/schema)
