Skip to main content
Neon Docs

Search documentation

Type to search this documentation.

Retrieve project consumption metrics

GET/consumption_history/v2/projectsRetrieve project consumption metrics

Returns consumption metrics for up to limit projects per page. If project_ids is omitted, projects in the organization are included across pages (use cursor). If project_ids is provided, the response is limited to those projects (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 project are returned in ascending time order (oldest first). This request does not wake project computes.

Parameters

cursorstringquery

Cursor from the previous response (`pagination.cursor`). Pass it to fetch the next page of projects. Pages are ordered by project creation order (newest first).

limitintegerquery

Maximum number of projects per page. Allowed range: 1 to 100. Default: 10.

default 10 · maximum 100 · minimum 1

project_idsarrayquery

Optional project IDs to filter the response (up to 100). If omitted, projects in the organization are included across pages (use `cursor` and `limit`). 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`

maxItems 100 · minItems 0

fromstring · date-timequeryrequired

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.

tostring · date-timequeryrequired

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.

granularitystringqueryrequired

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

one of "hourly", "daily", "monthly"

one of "hourly", "daily", "monthly"

org_idstringqueryrequired

Organization ID. Metrics are returned for projects in this organization.

pattern ^[a-z0-9-]{1,60}$

metricsarrayqueryrequired

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`

Responses

200Project consumption metrics for the Neon account.application/json
value
allOf · 2 options
Option 1objectConsumptionHistoryPerProjectV2Response
projectsarray of objectrequired

Per-project consumption history entries for the requested time range.

Show child attributes
Show array items
periodsarray of objectrequired

Consumption periods recorded for this project.

Show child attributes
Show array items
consumptionarray of objectrequired

Consumption metric records for the billing period.

Show child attributes
Show array items
metricsarray of object

Consumption metric values recorded for the timeframe.

Show child attributes
Show array items
metric_namestringrequired

Name of the consumption metric, such as compute_time or data_storage_bytes_hour.

valueintegerrequired

Measured quantity for the metric named by `metric_name`.

timeframe_endstring · date-time

The specified end date-time for the reported consumption.

timeframe_startstring · date-time

The specified start date-time for the reported consumption.

period_endstring · date-time

The end date-time of the billing period, available for the past periods only.

period_idstring · uuidrequired

The ID assigned to the specified billing period.

period_planstringrequired

The billing plan applicable during the billing period.

period_startstring · date-timerequired

The start date-time of the billing period.

project_idstringrequired

The Neon project ID. Returned as `id` from `GET /projects`.

pattern ^[a-z0-9-]{1,60}$

Option 2objectPaginationResponse
paginationobject

Cursor-based pagination. The `cursor` value reflects the endpoint's sort field (for example, an ID or timestamp), so pass it back unchanged.

Show child attributes
cursorstringrequired

Cursor marking the last item in this response. Pass it unchanged as the `cursor` query parameter to fetch the next page.

minLength 1

Example response
{
  "pagination": {
    "cursor": "2022-12-07T00:45:05.262011Z"
  },
  "projects": [
    {
      "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"
    }
  ]
}
403Not available for this account. Project consumption history requires a Launch, Scale, Agent, Business, or Enterprise plan. application/json
objectGeneralError
codestringrequired

default ""

messagestringrequired

Error message

request_idstring

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.

Example response
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
404Account is not a member of the organization specified by `org_id`.application/json
objectGeneralError
codestringrequired

default ""

messagestringrequired

Error message

request_idstring

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.

Example response
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
406The `from` and `to` range is not valid for the selected `granularity`. Adjust the range or choose a different granularity. application/json
objectGeneralError
codestringrequired

default ""

messagestringrequired

Error message

request_idstring

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.

Example response
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
429Too many requestsapplication/json
objectGeneralError
codestringrequired

default ""

messagestringrequired

Error message

request_idstring

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.

Example response
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
defaultGeneral 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
objectGeneralError
codestringrequired

default ""

messagestringrequired

Error message

request_idstring

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.

Example response
{
  "code": "",
  "message": "string",
  "request_id": "string"
}
Documentation menu