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

# Query meter

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

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 — [RFC3339](https://tools.ietf.org/html/rfc3339) formatted date-time string in UTC.
  - `to` string, date-time — [RFC3339](https://tools.ietf.org/html/rfc3339) formatted date-time string in UTC.
  - `granularity` 'PT1M' | 'PT1H' | 'P1D' | 'P1M' — The granularity of the time grouping. Time durations are specified in ISO 8601 format.
  - `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` MeterQueryFilters — Filters to apply to a meter 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 — [RFC3339](https://tools.ietf.org/html/rfc3339) formatted date-time string in UTC.
  - `to` string, date-time — [RFC3339](https://tools.ietf.org/html/rfc3339) formatted date-time string in UTC.
  - `data` MeterQueryRow[], required — The usage data. If no data is available, an empty array is returned.
    - `value` string, required — Numeric represents an arbitrary precision number.
    - `from` string, date-time, required — [RFC3339](https://tools.ietf.org/html/rfc3339) formatted date-time string in UTC.
    - `to` string, date-time, required — [RFC3339](https://tools.ietf.org/html/rfc3339) formatted date-time string in UTC.
    - `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/openmeterio/apis/openmeter-and-konnect-metering-billing-api.md) · [All operations](https://skmtc.net/openmeterio/apis/openmeter-and-konnect-metering-billing-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/openmeterio/openmeter-and-konnect-metering-billing-api/versions/9bca44e2d61d/schema)
