---
title: "Usage"
method: GET
path: "/analytics/usage"
tags: ["analytics"]
---

# Usage

`GET /analytics/usage`

## Query parameters

- `from_date` string, date-time, nullable — Start date for the time range (inclusive). If not provided, defaults to the first day of the current month.
- `to_date` string, date-time, nullable — End date for the time range (exclusive). If not provided, defaults to the last day of the current month.
- `granularity` 'minute' | 'hour' | 'day' | 'month' | 'year'
- `fields` string[], nullable — Fields from event_metadata to include and sum
- `group_by` string[], nullable — Fields from tags to group by
- `session_id` string, nullable — If provided, narrow the result to events tagged with this session_id (set by the URL-session prefix /v3/session/<sid>). Useful for `opper launch` style accounting.

## Response `200`

Successful Response

- GetUsageResultItem[]
  - `time_bucket` string, date-time, required — The start time of the time bucket
  - `cost` string, required — The cost in USD for the time bucket

## Other responses

- `400` — Bad Request
- `401` — Unauthorized
- `402` — Payment Required (out of credits)
- `404` — Not Found
- `422` — Request Validation Error

---

[API](https://skmtc.dev/opper/apis/opper-api-v2.md) · [All operations](https://skmtc.dev/opper/apis/opper-api-v2/llms.txt) · [OpenAPI document](https://skmtc-service-production.skmtc.workers.dev/v1/apis/opper/opper-api-v2/revisions/d3ccdaa15678/schema)
