# Usage

The Usage API returns your program's status against your plan: active frameworks, connected integrations, and team members for your account, organization, or individual programs.

## Scope

Status is available at three levels:

- **Account**: status across all programs you own.
- **Organization**: status across an organization's programs. See [Organization usage](/docs/manage/orgs-api-consumption).
- **Program**: per-program status.

> **Note:** Two sets of usage endpoints exist. `GET /consumption_history/v2/projects` returns status for current plans (Start, Professional, Enterprise). `GET /consumption_history/projects` covers legacy plan status. See [Query usage](/docs/guides/consumption-metrics) for endpoint details and when to use each.

To understand your plan, see [Plans](/docs/introduction/plans) and [Manage billing](/docs/introduction/manage-billing).

---

> API Reference / Usage / Retrieve program consumption metrics (legacy plans)

## GET /consumption_history/programs

Retrieves consumption metrics for Scale, Business, and Enterprise plan programs. History begins at the time of upgrade.
Results are ordered by time in ascending order (oldest to newest).
Issuing a call to this API does not wake a program's integration.


### Parameters

- `cursor` (string, query, optional)
  Specify the cursor value from the previous response to get the next batch of programs.
- `limit` (integer, query, optional)
  Specify a value from 1 to 100 to limit number of programs in the response.
  Default: `10`
- `program_ids` (array, query, optional)
  Specify a list of program IDs to filter the response.
  If omitted, the response will contain all programs.
  A list of program IDs can be specified as an array of parameter values or as a comma-separated list in a single parameter value.
  - As an array of parameter values: `program_ids=cold-poetry-09157238%20&program_ids=quiet-snow-71788278`
  - As a comma-separated list in a single parameter value: `program_ids=cold-poetry-09157238,quiet-snow-71788278`
  
- `from` (string, query, required)
  Specify the start `date-time` for the consumption period.
  The `date-time` value is rounded according to the specified `granularity`.
  For example, `2024-03-15T15:30:00Z` for `daily` granularity will be rounded to `2024-03-15T00:00:00Z`.
  The specified `date-time` value must respect the specified `granularity`:
  - For `hourly`, consumption metrics are limited to the last 168 hours.
  - For `daily`, consumption metrics are limited to the last 60 days.
  - For `monthly`, consumption metrics are limited to the last year.
  
  The consumption history is available starting from `March 1, 2024, at 00:00:00 UTC`.
  
- `to` (string, query, required)
  Specify the end `date-time` for the consumption period.
  The `date-time` value is rounded according to the specified granularity.
  For example, `2024-03-15T15:30:00Z` for `daily` granularity will be rounded to `2024-03-15T00:00:00Z`.
  The specified `date-time` value must respect the specified `granularity`:
  - For `hourly`, consumption metrics are limited to the last 168 hours.
  - For `daily`, consumption metrics are limited to the last 60 days.
  - For `monthly`, consumption metrics are limited to the last year.
  
- `granularity` (string, query, required)
  Specify the granularity of consumption metrics.
  Hourly, daily, and monthly metrics are available for the last 168 hours, 60 days,
  and 1 year, respectively.
  
- `org_id` (string, query, optional)
  Specify the organization for which the program consumption metrics should be returned.
  If this parameter is not provided, the endpoint will return the metrics for the
  authenticated user's programs.
  
- `include_v1_metrics` (boolean, query, optional)
  The field is deprecated. Please use `metrics` instead.
  If `metrics` is specified, this field is ignored.
  Include metrics utilized in previous pricing models.
  - **data_storage_bytes_hour**: The sum of the maximum observed storage values for each hour,
    which never decreases.
  
- `metrics` (array, query, optional)
  Specify a list of metrics to include in the response.
  If omitted, active_time, compute_time, written_data, synthetic_storage_size are returned.
  Possible values:
  - `active_time_seconds`
  - `compute_time_seconds`
  - `written_data_bytes`
  - `synthetic_storage_size_bytes`
  - `data_storage_bytes_hour`
  - `logical_size_bytes`
  - `logical_size_bytes_hour`
  
  A list of metrics can be specified as an array of parameter values or as a comma-separated list in a single parameter value.
  - As an array of parameter values: `metrics=cpu_seconds&metrics=ram_bytes`
  - As a comma-separated list in a single parameter value: `metrics=cpu_seconds,ram_bytes`
  

### Response (200)

```json
{
  "programs": [
    {
      "program_id": "quiet-river-789012",
      "periods": [
        {
          "period_id": "00000000-0000-0000-0000-000000000000",
          "period_plan": "scale",
          "period_start": "2025-01-15T10:30:00Z",
          "consumption": [
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 652,
              "compute_time_seconds": 166,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 31434888
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 968,
              "compute_time_seconds": 254,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 31602992
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 0,
              "compute_time_seconds": 0,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 31536368
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 0,
              "compute_time_seconds": 0,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 31334400
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 0,
              "compute_time_seconds": 0,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 31334400
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 0,
              "compute_time_seconds": 0,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 31334400
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 0,
              "compute_time_seconds": 0,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 31334400
            }
          ]
        }
      ]
    },
    {
      "program_id": "bright-meadow-654321",
      "periods": [
        {
          "period_id": "00000000-0000-0000-0000-000000000000",
          "period_plan": "scale",
          "period_start": "2025-01-15T10:30:00Z",
          "consumption": [
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 5448,
              "compute_time_seconds": 2960,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 510949592
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 83912,
              "compute_time_seconds": 21309,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 462717096
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 86400,
              "compute_time_seconds": 21617,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 109347248
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 86400,
              "compute_time_seconds": 21615,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 109283456
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 86400,
              "compute_time_seconds": 21626,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 109292088
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 86448,
              "compute_time_seconds": 21618,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 109292032
            },
            {
              "timeframe_start": "2025-01-15T10:30:00Z",
              "timeframe_end": "2025-01-15T10:30:00Z",
              "active_time_seconds": 86376,
              "compute_time_seconds": 21607,
              "written_data_bytes": 0,
              "synthetic_storage_size_bytes": 109291920
            }
          ]
        }
      ]
    },
    {
      "program_id": "dormant-slug-000036",
      "periods": []
    }
  ],
  "pagination": {
    "cursor": "dormant-slug-000041"
  }
}
```

### Code examples

```bash
curl "https://api.optitech.com/v1/consumption_history/programs?from=$FROM&to=$TO&granularity=$GRANULARITY" \
  -H "Authorization: Bearer $OPTITECH_API_KEY"
```

```typescript
import { createOptiTechClient, raw } from '@optitech/sdk';

const optitech = createOptiTechClient({ apiKey: process.env.OPTITECH_API_KEY });
const { data } = await raw.getConsumptionHistoryPerProject({
  client: optitech.client,
  query: {
    from: process.env.FROM,
    to: process.env.TO,
    granularity: process.env.GRANULARITY
  }
});
```

### Errors

**403**
This endpoint is not available. It is only supported with Scale, Business, and Enterprise plan accounts.
- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**404**
Account is not a member of the organization specified by `org_id`.
- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**406**
The specified `date-time` range is outside the boundaries of the specified `granularity`.
Adjust your `from` and `to` values or select a different `granularity`.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**429**
Too many requests
- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Usage / Retrieve program consumption metrics

## GET /consumption_history/v2/programs

Returns consumption metrics for up to `limit` programs per page. If `program_ids` is omitted,
projects in the organization are included across pages (use `cursor`). If `program_ids` is
provided, the response is limited to those programs (up to 100). Available for accounts on
Launch, Scale, Agent, Business, and Enterprise plans.

History starts when the account upgrades to an eligible plan.

The `metrics` query parameter is required. Supported values:
`compute_unit_seconds`, `root_branch_bytes_month`, `child_branch_bytes_month`,
`instant_restore_bytes_month`, `public_network_transfer_bytes`, `private_network_transfer_bytes`,
`extra_branches_month`, `snapshot_storage_bytes_month`.

Consumption metrics within each program are returned in ascending time order (oldest first).
This request does not wake program computes.


### Parameters

- `cursor` (string, query, optional)
  Cursor from the previous response (`pagination.cursor`). Pass it to fetch the next page
  of programs. Pages are ordered by program creation order (newest first).
  
- `limit` (integer, query, optional)
  Maximum number of programs per page. Allowed range: 1 to 100. Default: 10.
  
  Default: `10`
- `program_ids` (array, query, optional)
  Optional program IDs to filter the response (up to 100). If omitted, programs in the
  organization are included across pages (use `cursor` and `limit`).
  
  Pass multiple IDs as repeated query parameters or a comma-separated list:
  - `program_ids=cold-poetry-09157238&program_ids=quiet-snow-71788278`
  - `program_ids=cold-poetry-09157238,quiet-snow-71788278`
  
- `from` (string, query, required)
  Specify the start `date-time` for the consumption period.
  The `date-time` value is rounded according to the specified `granularity`.
  For example, `2024-03-15T15:30:00Z` for `daily` granularity will be rounded to `2024-03-15T00:00:00Z`.
  The specified `date-time` value must respect the specified `granularity`:
  - For `hourly`, consumption metrics are limited to the last 168 hours.
  - For `daily`, consumption metrics are limited to the last 60 days.
  - For `monthly`, consumption metrics are limited to the last year.
  
  The earliest allowed `from` value is `March 1, 2024, at 00:00:00 UTC`.
  Metrics are returned from when the account upgraded to an eligible plan, which may be
  later than that date.
  
- `to` (string, query, required)
  Specify the end `date-time` for the consumption period.
  The `date-time` value is rounded according to the specified `granularity`.
  For example, `2024-03-15T15:30:00Z` for `daily` granularity will be rounded to `2024-03-15T00:00:00Z`.
  The specified `date-time` value must respect the specified `granularity`:
  - For `hourly`, consumption metrics are limited to the last 168 hours.
  - For `daily`, consumption metrics are limited to the last 60 days.
  - For `monthly`, consumption metrics are limited to the last year.
  
- `granularity` (string, query, required)
  Specify the granularity of consumption metrics.
  Hourly, daily, and monthly metrics are available for the last 168 hours, 60 days,
  and 1 year, respectively.
  
- `org_id` (string, query, required)
  Organization ID. Metrics are returned for programs in this organization.
  
- `metrics` (array, query, required)
  Required. List the metrics to return. Supported values:
  - `compute_unit_seconds`
  - `root_branch_bytes_month`
  - `child_branch_bytes_month`
  - `instant_restore_bytes_month`
  - `public_network_transfer_bytes`
  - `private_network_transfer_bytes`
  - `extra_branches_month`
  - `snapshot_storage_bytes_month`
  
  Pass multiple values as repeated query parameters or a comma-separated list:
  - `metrics=compute_unit_seconds&metrics=extra_branches_month`
  - `metrics=compute_unit_seconds,extra_branches_month`
  

### Response (200)

```json
{
  "programs": [
    {
      "program_id": "dormant-slug-000038",
      "periods": []
    },
    {
      "program_id": "dormant-slug-000042",
      "periods": []
    },
    {
      "program_id": "dormant-slug-000043",
      "periods": []
    },
    {
      "program_id": "dormant-slug-000036",
      "periods": []
    },
    {
      "program_id": "dormant-slug-000040",
      "periods": []
    },
    {
      "program_id": "dormant-slug-000041",
      "periods": []
    },
    {
      "program_id": "bright-meadow-654321",
      "periods": []
    },
    {
      "program_id": "quiet-river-789012",
      "periods": []
    },
    {
      "program_id": "dormant-slug-000039",
      "periods": []
    },
    {
      "program_id": "dormant-slug-000037",
      "periods": []
    }
  ],
  "pagination": {
    "cursor": "dormant-slug-000041"
  }
}
```

### Code examples

```bash
curl "https://api.optitech.com/v1/consumption_history/v2/programs?from=$FROM&to=$TO&granularity=$GRANULARITY&org_id=$ORG_ID&metrics=$METRICS" \
  -H "Authorization: Bearer $OPTITECH_API_KEY"
```

```typescript
import { createOptiTechClient, raw } from '@optitech/sdk';

const optitech = createOptiTechClient({ apiKey: process.env.OPTITECH_API_KEY });
const { data } = await raw.getConsumptionHistoryPerProjectV2({
  client: optitech.client,
  query: {
    from: process.env.FROM,
    to: process.env.TO,
    granularity: process.env.GRANULARITY,
    org_id: process.env.ORG_ID,
    metrics: process.env.METRICS
  }
});
```

### Errors

**403**
Not available for this account. Program consumption history requires a Launch, Scale,
Agent, Business, or Enterprise plan.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**404**
Account is not a member of the organization specified by `org_id`.
- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**406**
The `from` and `to` range is not valid for the selected `granularity`. Adjust the range or
choose a different granularity.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**429**
Too many requests
- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

---

> API Reference / Usage / Retrieve framework consumption metrics

## GET /consumption_history/v2/frameworks

Returns consumption metrics for each framework across one or more programs listed in
`program_ids` (1 to 100 programs). Available for accounts on paid usage-based Launch, Scale,
Agent, and Enterprise plans.

History starts when the account first ingests framework-level consumption data.

The `metrics` query parameter is required. Only these six values are supported on this
endpoint:
`compute_unit_seconds`, `root_branch_bytes_month`, `child_branch_bytes_month`,
`instant_restore_bytes_month`, `public_network_transfer_bytes`, `private_network_transfer_bytes`.

This endpoint does not support `extra_branches_month` or `snapshot_storage_bytes_month`.
Use `GET /consumption_history/v2/programs` for those.

Consumption metrics within each framework are returned in ascending time order (oldest first).
This request does not wake program computes.


### Parameters

- `cursor` (string, query, optional)
  Cursor from the previous response (`pagination.cursor`). Pass it to fetch the next page
  of frameworks. Pages are ordered by program ID, then framework ID.
  
- `limit` (integer, query, optional)
  Maximum number of frameworks per page. Allowed range: 1 to 1000. Default: 100.
  
  Default: `100`
- `program_ids` (array, query, required)
  Program IDs to include (required, 1 to 100). Returns metrics for frameworks in these programs.
  
  Pass multiple IDs as repeated query parameters or a comma-separated list:
  - `program_ids=cold-poetry-09157238&program_ids=quiet-snow-71788278`
  - `program_ids=cold-poetry-09157238,quiet-snow-71788278`
  
- `branch_ids` (array, query, optional)
  Optional framework IDs to filter the response (up to 100). If omitted, all frameworks in the
  listed programs are included.
  
  Pass multiple IDs as repeated query parameters or a comma-separated list:
  - `branch_ids=br-aged-salad-637688&branch_ids=br-sweet-breeze-497520`
  - `branch_ids=br-aged-salad-637688,br-sweet-breeze-497520`
  
- `from` (string, query, required)
  Specify the start `date-time` for the consumption period.
  The `date-time` value is rounded according to the specified `granularity`.
  For example, `2024-03-15T15:30:00Z` for `daily` granularity will be rounded to `2024-03-15T00:00:00Z`.
  The specified `date-time` value must respect the specified `granularity`:
  - For `hourly`, consumption metrics are limited to the last 168 hours.
  - For `daily`, consumption metrics are limited to the last 60 days.
  - For `monthly`, consumption metrics are limited to the last year.
  
  Branch-level metrics are returned from when the account first ingests framework-level
  consumption data. Periods before that time contain no framework metrics.
  
- `to` (string, query, required)
  Specify the end `date-time` for the consumption period.
  The `date-time` value is rounded according to the specified `granularity`.
  For example, `2024-03-15T15:30:00Z` for `daily` granularity will be rounded to `2024-03-15T00:00:00Z`.
  The specified `date-time` value must respect the specified `granularity`:
  - For `hourly`, consumption metrics are limited to the last 168 hours.
  - For `daily`, consumption metrics are limited to the last 60 days.
  - For `monthly`, consumption metrics are limited to the last year.
  
- `granularity` (string, query, required)
  Specify the granularity of consumption metrics.
  Hourly, daily, and monthly metrics are available for the last 168 hours, 60 days,
  and 1 year, respectively.
  
- `org_id` (string, query, required)
  Organization ID. Metrics are returned for programs in this organization.
  
- `metrics` (array, query, required)
  Required. List the metrics to return. Only these values are supported:
  - `compute_unit_seconds`
  - `root_branch_bytes_month`
  - `child_branch_bytes_month`
  - `instant_restore_bytes_month`
  - `public_network_transfer_bytes`
  - `private_network_transfer_bytes`
  
  Not supported on this endpoint: `extra_branches_month`, `snapshot_storage_bytes_month`.
  Use `GET /consumption_history/v2/programs` for those.
  
  Pass multiple values as repeated query parameters or a comma-separated list:
  - `metrics=compute_unit_seconds&metrics=public_network_transfer_bytes`
  - `metrics=compute_unit_seconds,public_network_transfer_bytes`
  

### Response (200)

- `frameworks` (array, optional)
  - `program_id` (string, required)
    The program that owns the framework
  - `framework_id` (string, required)
    The framework ID
  - `periods` (array, required)
    - `period_id` (string, required, format: uuid)
      The ID assigned to the specified billing period.
    - `period_plan` (string, required)
      The billing plan applicable during the billing period.
    - `period_start` (string, required, format: date-time)
      The start date-time of the billing period.
      
    - `period_end` (string, optional, format: date-time)
      The end date-time of the billing period, available for the past periods only.
      
    - `consumption` (array, required)
      - `timeframe_start` (string, optional, format: date-time)
        The specified start date-time for the reported consumption.
        
      - `timeframe_end` (string, optional, format: date-time)
        The specified end date-time for the reported consumption.
        
      - `metrics` (array, optional)
        - `metric_name` (string, required)
        - `value` (integer, required)
- `pagination` (object, optional)
  Cursor based pagination is used. The user must pass the cursor as is to the backend.
  For more information about cursor based pagination, see
  https://learn.microsoft.com/en-us/ef/core/querying/pagination#keyset-pagination
  
  - `cursor` (string, required)

### Code examples

```bash
curl "https://api.optitech.com/v1/consumption_history/v2/frameworks?program_ids=$PROGRAM_IDS&from=$FROM&to=$TO&granularity=$GRANULARITY&org_id=$ORG_ID&metrics=$METRICS" \
  -H "Authorization: Bearer $OPTITECH_API_KEY"
```

```typescript
import { createOptiTechClient, raw } from '@optitech/sdk';

const optitech = createOptiTechClient({ apiKey: process.env.OPTITECH_API_KEY });
const { data } = await raw.getConsumptionHistoryPerBranchV2({
  client: optitech.client,
  query: {
    program_ids: process.env.PROGRAM_IDS,
    from: process.env.FROM,
    to: process.env.TO,
    granularity: process.env.GRANULARITY,
    org_id: process.env.ORG_ID,
    metrics: process.env.METRICS
  }
});
```

### Errors

**403**
Not available for this account. Framework consumption history requires a paid usage-based
Launch, Scale, Agent, or Enterprise plan.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**404**
Account is not a member of the organization specified by `org_id`.
- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**406**
The `from` and `to` range is not valid for the selected `granularity`. Adjust the range or
choose a different granularity.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**429**
Too many requests
- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message

**default**
General Error.

The request may or may not be safe to retry, depending on the HTTP method, response status code,
and whether a response was received.

- If no response is returned from the API, a network error or timeout likely occurred.
- In some cases, the request may have reached the server and been successfully processed, but the response failed to reach the client. As a result, retrying non-idempotent requests can lead to unintended results.

The following HTTP methods are considered non-idempotent: `POST`, `PATCH`, `DELETE`, and `PUT`. Retrying these methods is generally **not safe**.
The following methods are considered idempotent: `GET`, `HEAD`, and `OPTIONS`. Retrying these methods is **safe** in the event of a network error or timeout.

Any request that returns a `503 Service Unavailable` response is always safe to retry.

Any request that returns a `423 Locked` response is safe to retry. `423 Locked` indicates that the resource is temporarily locked, for example, due to another operation in progress.

- `request_id` (string, optional)
  Unique identifier for the request, useful for debugging.
  You can set this value manually by including an `X-Request-ID` header in the request. If not provided, the value will be generated automatically.
  
- `code` (string, required)
  Default: ``
- `message` (string, required)
  Error message
