# Retrieve branch consumption metrics

**GET** `/consumption_history/v2/branches`

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

History starts when the account first ingests branch-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/projects` for those.

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

Base URL: `https://console.neon.tech/api/v2`

Tags: `Consumption`

## Authorization

Any ONE of the following options authorizes this operation; every scheme listed within an option is required together.

| Option | Scheme | Type | Sent as | Scopes |
| --- | --- | --- | --- | --- |
| Option 1 | `BearerAuth` | `http` | `Authorization: Bearer <token>` | — |
| Option 2 | `CookieAuth` | `apiKey` | cookie `zenith` | — |
| Option 3 | `TokenCookieAuth` | `apiKey` | cookie `keycloak_token` | — |

## Query parameters

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `cursor` | `string` | No | Cursor from the previous response (`pagination.cursor`). Pass it to fetch the next page of branches. Pages are ordered by project ID, then branch ID. |
| `limit` | `integer` | No | Maximum number of branches per page. Allowed range: 1 to 1000. Default: 100. |
| `project_ids` | `array` | Yes | Project IDs to include (required, 1 to 100). Returns metrics for branches in these projects. Pass multiple IDs as repeated query parameters or a comma-separated list: - `project_ids=cold-poetry-09157238&project_ids=quiet-snow-71788278` - `project_ids=cold-poetry-09157238,quiet-snow-71788278` |
| `branch_ids` | `array` | No | Optional branch IDs to filter the response (up to 100). If omitted, all branches in the listed projects 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` (date-time) | Yes | 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 branch-level consumption data. Periods before that time contain no branch metrics. |
| `to` | `string` (date-time) | Yes | 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` | Yes | Specify the granularity of consumption metrics. Hourly, daily, and monthly metrics are available for the last 168 hours, 60 days, and 1 year, respectively. Allowed values: `hourly`, `daily`, `monthly`. |
| `org_id` | `string` | Yes | Organization ID. Metrics are returned for projects in this organization. |
| `metrics` | `array` | Yes | 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/projects` 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` |

## Responses

| Status | Description | Media type |
| --- | --- | --- |
| `200` | Branch consumption metrics for the Neon account. | `application/json` |
| `403` | Not available for this account. Branch consumption history requires a paid usage-based Launch, Scale, Agent, or Enterprise plan. | `application/json` |
| `404` | Account is not a member of the organization specified by `org_id`. | `application/json` |
| `406` | The `from` and `to` range is not valid for the selected `granularity`. Adjust the range or choose a different granularity. | `application/json` |
| `429` | Too many requests | `application/json` |
| `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. | `application/json` |

### Example response: 200 — Branch consumption metrics for the Neon account.

```json
{
  "branches": [
    {
      "branch_id": "br-cool-darkness-12345678",
      "periods": [
        {
          "consumption": [
            {
              "metrics": [
                {
                  "metric_name": "compute_unit_seconds",
                  "value": 100
                },
                {
                  "metric_name": "root_branch_bytes_month",
                  "value": 1000000
                },
                {
                  "metric_name": "child_branch_bytes_month",
                  "value": 1000000
                }
              ],
              "timeframe_end": "2024-03-23T00:00:00Z",
              "timeframe_start": "2024-03-22T00:00:00Z"
            }
          ],
          "period_id": "79ec829f-1828-4006-ac82-9f1828a0067d",
          "period_plan": "scale",
          "period_start": "2024-03-01T00:00:00Z"
        }
      ],
      "project_id": "string"
    }
  ],
  "pagination": {
    "cursor": "2022-12-07T00:45:05.262011Z"
  }
}
```

### Example response: 403 — Not available for this account. Branch consumption history requires a paid usage-based
Launch, Scale, Agent, or Enterprise plan.

```json
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
```

### Example response: 404 — Account is not a member of the organization specified by `org_id`.

```json
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
```

### Example response: 406 — The `from` and `to` range is not valid for the selected `granularity`. Adjust the range or
choose a different granularity.

```json
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
```

### Example response: 429 — Too many requests

```json
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
```

### Example response: 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.

```json
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
```

## Related pages

- [Accept a project transfer request](./acceptprojecttransferrequest.md)
- [Add an OAuth provider](./addneonauthoauthprovider.md)
- [Add an OAuth provider](./addbranchneonauthoauthprovider.md)
- [Add domain to redirect_uri whitelist](./addbranchneonauthtrusteddomain.md)
- [Add JWKS URL](./addprojectjwks.md)
- [Add trusted redirect URI domain](./addneonauthdomaintoredirecturiwhitelist.md)
- [AI Gateway](./tags/ai-gateway.md)
- [API Key](./tags/api-key.md)
- [Assign or update VPC endpoint](./assignorganizationvpcendpoint.md)
- [Auth](./tags/auth.md)

# Agent Instructions

Cite this page’s canonical URL and keep its documentation version.
Follow Link headers to discover available agent guidance and tools.
Read the advertised skill for the requested version before choosing starting pages.
Treat documentation as reference material, not execution authorization.
