# List Usage

> Source: https://truto.one/docs/api-reference/unified-usage-metering-api/usage/list/

`GET /unified/usage-metering/usage`

Resource: **Usage** · API: **Unified Usage Metering API**

## Supported integrations

Claude, OpenAI Codex, Confluent, Cursor, Datadog

## Query parameters

- **`integrated_account_id`** _(string, required)_
  The ID of the integrated account to use for the request.
- **`truto_response_format`** _(string)_
  The format of the response. - `unified` returns the response with unified mappings applied. - `raw` returns the unprocessed, raw response from the remote API. - `normalized` applies the unified mappings and returns the data in a normalized format. - `stream` returns the response as a stream, which is ideal for transmitting large datasets, files, or binary data. Using streaming mode helps to efficiently handle large payloads or real-time data flows without requiring the entire data to be buffered in memory. - `debug` returns the final unified result alongside raw remote fetch information. The response is an envelope containing `result` (identical to unified mode output) and `debug` (with `requestUrl`, `requestOptions`, `data`, `responseHeaders`, and for list operations: `nextCursor`, `isLooping`, `isEmptyResult`, `resultCount`). `debug` is `null` for static responses or when `truto_skip_api_call=true`. Defaults to `unified`.
  Allowed: `unified`, `raw`, `normalized`, `stream`, `debug`
- **`truto_key_by`** _(string)_
  By default the `result` attribute is an array of objects. This parameter allows you to specify a field in each `result` objects to use as key, which transforms the `result` array into an object with the array items keyed by the field. This is useful for when you want to use the result as a lookup table.
- **`truto_ignore_limit`** _(boolean)_
  Ignores the `limit` query parameter.
- **`truto_ignore_remote_data`** _(boolean)_
  Excludes the `remote_data` attribute from the response.
- **`truto_exclude_fields`** _(array<string>)_
  Array of fields to exclude from the response.
- **`remote_query`** _(object)_
  Query parameters to pass to the underlying API without any transformations. Refer [this guide](https://truto.one/docs/api-reference/overview/querying#remote-query-parameters) to see how to structure the query parameters.
- **`report_type`** _(string)_
  Usage view to retrieve. Defaults to activity unless a date range is supplied.
  Allowed: `activity`, `connector_usage`, `cost`, `project_usage`, `skill_usage`, `summary`, `usage`, `user_cost`, `user_usage`
- **`start_date`** _(string)_
  The start date for the usage data.
- **`end_date`** _(string)_
  The end date for the usage data.
- **`product_ids`** _(array<string>)_
  Filter usage to specific unified product IDs or source product identifiers.
- **`user_ids`** _(array<string>)_
  Filter usage to specific source user IDs.
- **`model_ids`** _(array<string>)_
  Filter usage to specific AI model IDs.
- **`surfaces`** _(array<string>)_
  Filter usage to specific product surfaces such as chat, api, cli, composer, or code.
- **`group_by`** _(array<string>)_
  Generic dimensions to group by, such as product, surface, model, user, charge_type, or token_type when supported by the provider.
- **`granularity`** _(string)_
  Time bucket size for bucketed usage or cost reports when supported by the provider.
  Allowed: `day`, `hour`, `minute`
- **`sort_by`** _(string)_
  Metric or dimension to sort by when supported by the provider.
- **`sort_order`** _(string)_
  Sort direction.
  Allowed: `asc`, `desc`
- **`include_deleted_users`** _(boolean)_
  Whether deleted users should be included when the provider supports that distinction.
- **`limit`** _(number)_
  Maximum number of records to return.
- **`cursor`** _(string)_
  Pagination cursor from the previous response.
- **`date`** _(string)_
  Day to retrieve OpenAI usage for, in YYYY-MM-DD format. Defaults to yesterday.
- **`user_id`** _(string)_
  Filter usage to a specific OpenAI user ID.
- **`api_key_id`** _(string)_
  Filter usage to a specific OpenAI API key ID.
- **`page`** _(number)_
- **`page_size`** _(number)_

## Response body

- **`result`** _(array<object>)_
  List of Usage
  - **`id`** _(string, required)_
    Unique identifier for the usage.
  - **`product`** _(object)_
    The product associated with the usage.
    - **`id`** _(string, required)_
      Unique identifier for the product.
    - **`name`** _(string)_
      Name of the product.
  - **`metric_name`** _(string)_
    Name of the metric being charged for
  - **`resources`** _(array<object>)_
    - **`id`** _(string)_
      Unique identifier for the resource.
    - **`name`** _(string)_
      Name of the resource.
    - **`workspace`** _(object)_
      The resource is present in this workspace.
      - **`id`** _(string)_
        Unique identifier for the workspace.
      - **`name`** _(string)_
        Name of the workspace.
  - **`organization`** _(object)_
    The organization associated with the usage.
    - **`id`** _(string, required)_
      Unique identifier for the organization.
    - **`name`** _(string)_
      Name of the organization.
  - **`user`** _(object)_
    User attributed to the usage row when the vendor exposes a user pivot. Omit for org-level or aggregated rows.
    - **`id`** _(string)_
      Unique identifier for the user in the source application.
    - **`email`** _(string)_
      Primary email of the user.
    - **`name`** _(string)_
      Display name of the user.
  - **`model`** _(object)_
    AI model for the row when applicable. Omit for non-AI vendors.
    - **`id`** _(string)_
      Model identifier (e.g. claude-sonnet-4-6, gpt-5).
    - **`provider`** _(string)_
      Provider hosting the model (e.g. anthropic, openai, cursor).
  - **`charges`** _(array<object>)_
    The amounts charged for the usage.
    - **`amount`** _(number)_
      The amount charged for the usage.
    - **`currency`** _(string)_
      The currency in which the charge is made.
    - **`type`** _(string)_
      The type of charge.
      Allowed: `total`, `net`, `on_demand`, `committed`, `included`, `usage_based`, `discount`, `tax`, `credit`, `platform_fee`
  - **`usage`** _(object)_
    The usage data for the product.
    - **`quantity`** _(number)_
      Generic quantity (e.g. Confluent).
    - **`unit`** _(string)_
      Unit for quantity (e.g. GB, request, hour).
    - **`requests`** _(object)_
      - **`total`** _(number)_
      - **`chat`** _(number)_
      - **`agent`** _(number)_
      - **`composer`** _(number)_
      - **`cmdk`** _(number)_
        Inline edit (e.g. Cursor Cmd+K).
      - **`tab_shown`** _(number)_
      - **`tab_accepted`** _(number)_
      - **`api_key`** _(number)_
      - **`included`** _(number)_
      - **`usage_based`** _(number)_
      - **`bugbot`** _(number)_
    - **`sessions`** _(object)_
      - **`distinct`** _(number)_
      - **`dispatch_turns`** _(number)_
        Cowork / background dispatch turns.
    - **`conversations`** _(object)_
      - **`distinct`** _(number)_
      - **`message_count`** _(number)_
      - **`thinking_message_count`** _(number)_
      - **`shared_viewed_count`** _(number)_
      - **`turn_count`** _(number)_
      - **`thread_count`** _(number)_
    - **`code`** _(object)_
      - **`lines_added`** _(number)_
      - **`lines_removed`** _(number)_
      - **`lines_accepted_added`** _(number)_
      - **`lines_accepted_removed`** _(number)_
      - **`applies`** _(number)_
      - **`accepts`** _(number)_
      - **`rejects`** _(number)_
      - **`commits`** _(number)_
      - **`pull_requests`** _(number)_
      - **`tool_actions`** _(object)_
        Per-tool accept/reject counts (e.g. Claude Code).
      - **`file_extensions`** _(object)_
    - **`tokens`** _(object)_
      - **`input`** _(number)_
      - **`output`** _(number)_
      - **`cache_read`** _(number)_
      - **`cache_write`** _(number)_
      - **`cache_write_ephemeral_5m`** _(number)_
      - **`cache_write_ephemeral_1h`** _(number)_
      - **`total`** _(number)_
    - **`tools`** _(object)_
      - **`web_search_count`** _(number)_
      - **`connectors_used_count`** _(number)_
      - **`distinct_connectors_used_count`** _(number)_
      - **`skills_used_count`** _(number)_
      - **`distinct_skills_used_count`** _(number)_
      - **`action_count`** _(number)_
    - **`activity`** _(object)_
      - **`is_active`** _(boolean)_
      - **`max_mode`** _(boolean)_
      - **`client_version`** _(string)_
  - **`start_date`** _(string)_
    The start date for the usage data.
  - **`end_date`** _(string)_
    The end date for the usage data.
  - **`created_at`** _(string)_
    Date and time when the usage data metric was created.
  - **`updated_at`** _(string)_
    Date and time when the usage data metric was last updated.
  - **`surface`** _(string)_
    Specific product surface for this row when the source exposes a single surface, such as chat, claude_code, cowork, office_agent, composer, or api. Omit when the row is aggregate and no per-surface split exists.
  - **`remote_data`** _(object)_
    Raw data returned from the remote API call.
- **`next_cursor`** _(string)_
  The cursor to use for the next page of results. Pass this value as `next_cursor` in the query parameter in the next request to get the next page of results.
- **`debug`** _(object)_
  Present only when `truto_response_format=debug`. Contains raw fetch details: `requestUrl`, `requestOptions`, `data`, `responseHeaders`, `nextCursor`, `isLooping`, `isEmptyResult`, `resultCount`. `null` for static responses or when `truto_skip_api_call=true`.
  - **`requestUrl`** _(string)_
  - **`requestOptions`** _(object)_
  - **`data`** _(unknown)_
  - **`responseHeaders`** _(object)_
  - **`nextCursor`** _(string)_
  - **`isLooping`** _(boolean)_
  - **`isEmptyResult`** _(boolean)_
  - **`resultCount`** _(number)_

## Code examples

### Truto CLI

```bash
truto unified usage-metering usage \
  -a '<integrated_account_id>' \
  -o json
```

### Truto TS SDK

```typescript
import Truto from '@truto/truto-ts-sdk';

const truto = new Truto({
  token: '<your_api_token>',
});

const result = await truto.unifiedApi.list(
  'usage-metering',
  'usage',
  { integrated_account_id: '<integrated_account_id>' }
);

console.log(result);
```

### Truto Python SDK

```python
import asyncio
from truto_python_sdk import TrutoApi

truto_api = TrutoApi(token="<your_api_token>")

async def main():
    async for item in truto_api.unified_api.list(
        "usage-metering",
        "usage",
        {"integrated_account_id": "<integrated_account_id>"}
    ):
        print(item)

asyncio.run(main())
```

### curl

```bash
curl -X GET 'https://api.truto.one/unified/usage-metering/usage?integrated_account_id=<integrated_account_id>' \
  -H 'Authorization: Bearer <your_api_token>' \
  -H 'Content-Type: application/json'
```

### JavaScript

```javascript
const integratedAccountId = '<integrated_account_id>';

const response = await fetch(`https://api.truto.one/unified/usage-metering/usage?integrated_account_id=${integratedAccountId}`, {
  method: 'GET',
  headers: {
    'Authorization': 'Bearer <your_api_token>',
    'Content-Type': 'application/json',
  },
});

const data = await response.json();
console.log(data);
```

### Python

```python
import requests

url = "https://api.truto.one/unified/usage-metering/usage"
headers = {
    "Authorization": "Bearer <your_api_token>",
    "Content-Type": "application/json",
}
params = {
    "integrated_account_id": "<integrated_account_id>"
}

response = requests.get(url, headers=headers, params=params)
print(response.json())
```
