Manage Organizations using the Neon API
Learn how to manage Neon Organizations using the Neon API, including creating projects, transferring projects, and retrieving consumption metrics.
The org_id
is your organization's unique identifier, used to make sure your API requests are scoped to the right organization.
Finding your org_id
To find your organization's org_id
, navigate to your Organization's Settings page, where you'll find it under the General information section. Copy and use this ID in your API requests.
Using the API key
Currently, while in Early Access, you can’t generate organization-specific API keys. Instead, use your personal account API key. If you’re a member of the specified org_id
, these API requests will work. See API Keys for detail.
Creating a new project
You can create a new project within your organization by including org_id
in your POST
request. Here we'll create a new project for the organization org-ocean-art-12345678
.
Listing projects
To list all projects belonging to your organization, include org_id
in the GET /projects
request. For example, let's get a list of all projects for the organization org-ocean-art-12345678
, with the default limit of 10 projects per return:
Transfer projects
The Project Transfer API allows you to transfer projects from your personal Neon account to a specified organization account. See Transfer projects via API for details.
Consumption metrics
You can use the Neon API to retrieve three types of consumption metrics for your organization:
Metric | Description | Plan Availability |
---|---|---|
Account-level | Total usage across all projects in your organization | Scale plan only |
Project-level (granular) | Project-level metrics available at hourly, daily, or monthly level of granularity | Scale plan only |
Project-level (billing period) | Consumption metrics for each project in your Organization for the current billing period | All plans |
Account-level metrics
To get global totals for all projects in the organization org-ocean-art-12345678
, include the org_id
in the GET /consumption/projects
request. We also need to include:
- A start date
- An end date
- A level of granularity
In this case, we're asking for hourly metrics between June 30th and July 2nd, 2024.
The response will provide aggregated hourly consumption metrics, including active time, compute time, written data, and synthetic storage size, for each hour between June 30 and July 2.
Response
Project-level metrics (granular)
You can also get similar daily, hourly, or monthly metrics across a selected time period, but broken out for each individual project that belongs to your organization.
Using the endpoint GET /consumption_history/projects
, let's use the same start date, end date, and level of granularity as our account-level request: hourly metrics between June 30th and July 2nd, 2024.
Response
Project-level metrics (for the current billing period)
To get basic billing period-based consumption metrics for each project in the organization org-ocean-art-12345678
, include org_id
in the GET /projects
request for consumption metrics:
See more details about using this endpoint on the Manage billing with consumption limits page in our Partner Guide.
List all organizations you belong to
You can use the GET /users/me/organizations
request to retrieve a list of all organizations associated with your personal account.
The response will include details about each organization, including the org_id
, name, and creation date.