---
title: "Query meter"
method: POST
path: "/v3/openmeter/meters/{meterId}/query"
tags: ["Meters"]
---

# Query meter

`POST /v3/openmeter/meters/{meterId}/query`

**Pre-release Endpoint**
This endpoint is currently in beta and is subject to change.

Query a meter for usage.

Set `Accept: application/json` (the default) to get a structured JSON response.
Set `Accept: text/csv` to download the same data as a CSV file suitable for
spreadsheets. The CSV columns, in order, are:

`from, to, [subject,] [customer_id, customer_key, customer_name,] <dimensions...>, value`

The `subject` column is emitted only when `subject` is in the query's
`group_by_dimensions`. The three `customer_*` columns are emitted together only
when `customer_id` is in the query's `group_by_dimensions`.

## Path parameters

- `meterId` string, required — ULID (Universally Unique Lexicographically Sortable Identifier).

## Request body

- MeterQueryRequest — A meter query request.
  - `from` string, date-time — The start of the period the usage is queried from.
  - `to` string, date-time — The end of the period the usage is queried to.
  - `granularity` 'PT1M' | 'PT1H' | 'P1D' | 'P1M' — The size of the time buckets to group the usage into. If not specified, the usage is aggregated over the entire period.
  - `time_zone` string — The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones). The time zone is used to determine the start and end of the time buckets. If not specified, the UTC timezone will be used.
  - `group_by_dimensions` string[] — The dimensions to group the results by.
  - `filters` object — Filters to apply to the query.
    - `dimensions` object — Filters to apply to the dimensions of the query. For `subject` and `customer_id` only equals ("eq", "in") comparisons are supported.

## Response `200`

The request has succeeded.

- MeterQueryResult — Meter query result.
  - `from` string, date-time — The start of the period the usage is queried from.
  - `to` string, date-time — The end of the period the usage is queried to.
  - `data` MeterQueryRow[], required — The usage data. If no data is available, an empty array is returned.
    - `value` string, required — The aggregated value.
    - `from` string, date-time, required — The start of the time bucket the value is aggregated over.
    - `to` string, date-time, required — The end of the time bucket the value is aggregated over.
    - `dimensions` object, required — The dimensions the value is aggregated over. `subject` and `customer_id` are reserved dimensions.

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `403` — Forbidden
- `404` — Not Found

---

[API](https://skmtc.net/kong/apis/konnect-api-go-sdk.md) · [All operations](https://skmtc.net/kong/apis/konnect-api-go-sdk/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/kong/konnect-api-go-sdk/versions/0261aef4b1e2/schema)
