# Retrieve project consumption metrics (legacy plans)

`GET /consumption_history/projects`

Retrieves consumption metrics for Scale, Business, and Enterprise plan projects. 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 project's compute endpoint.

[Markdown for AI context](/guides/apis-sdks-reference-api-consumption-get-consumption-history-per-project)

```bash title="REST API - curl"
curl "https://console.neon.tech/api/v2/consumption_history/projects?from=$FROM&to=$TO&granularity=$GRANULARITY" \
  -H "Authorization: Bearer $NEON_API_KEY"
```

Every field below is optional. An empty body works too.

```typescript title="Also available in"
import { createNeonClient, raw } from '@neon/sdk';

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

## Parameters

Cursor

`cursor`

string

Specify the cursor value from the previous response to get the next batch of projects.

Limit

`limit`

integerdefault: 10

Specify a value from 1 to 100 to limit number of projects in the response.

Project IDs

`project_ids`

array

Specify a list of project IDs to filter the response. If omitted, the response will contain all projects. A list of project 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: `project_ids=cold-poetry-09157238%20&project_ids=quiet-snow-71788278`
- As a comma-separated list in a single parameter value: `project_ids=cold-poetry-09157238,quiet-snow-71788278`

From

`from`

string

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

`to`

string

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

`granularity`

string

Specify the granularity of consumption metrics. Hourly, daily, and monthly metrics are available for the last 168 hours, 60 days, and 1 year, respectively.

Organization

`org_id`

string

Specify the organization for which the project consumption metrics should be returned. If this parameter is not provided, the endpoint will return the metrics for the authenticated user's projects.

Include v1 metrics

`include_v1_metrics`

boolean

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

`metrics`

array

Specify a list of metrics to include in the response. If omitted, active\_time, compute\_time, written\_data are returned. Possible values:

- `active_time_seconds`
- `compute_time_seconds`
- `written_data_bytes`
- `synthetic_storage_size_bytes` (deprecated: always returns 0; use the consumption history v2 endpoints instead)
- `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

Returned project consumption metrics for the Neon account

::::tabs
:::tab{title="schema"}
Depth
:::

:::tab{title="example"}
:::
::::

## Errors

403

This endpoint is not available. It is only supported with Scale, Business, and Enterprise plan accounts.

404

Account is not a member of the organization specified by `org_id`.

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`.

429

Too many requests

default

General error

This endpoint can return the standard Neon API error response.

Response fields

- `message` Required. Human-readable error message.
- `code` Required. Machine-readable error code.
- `request_id` Optional. Request identifier for debugging. You can provide one with the `X-Request-ID` header.

Retry guidance

If no response is returned, the request may still have reached the server. This is why retry safety depends on the method and status code.

Idempotent methods (`GET`, `HEAD`, `OPTIONS`) are generally safe to retry after a network error or timeout. Non-idempotent methods (`POST`, `PATCH`, `DELETE`, `PUT`) can change state, so avoid automatic retries unless your workflow can tolerate duplicate effects.

Responses with `423 Locked` or `503 Service Unavailable` are safe to retry. `423 Locked` means the resource is temporarily locked, usually because another operation is in progress.

## Related pages

- [Retrieve branch consumption metrics](./apis-sdks-reference-api-consumption-get-consumption-history-per-branch-v2.md)
- [Retrieve project consumption metrics](./apis-sdks-reference-api-consumption-get-consumption-history-per-project-v2.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.
