Neon CLI commands β projects
Use the Neon CLI to manage Neon directly from the terminal
Before you begin
- Before running the
projects
command, ensure that you have installed the Neon CLI. - If you have not authenticated with the neon auth command, running a Neon CLI command automatically launches the Neon CLI browser authentication process. Alternatively, you can specify a Neon API key using the
--api-key
option when running a command. See Connect.
For information about projects in Neon, see Projects.
projects
command
The The projects
command allows you to list, create, update, delete, and retrieve information about Neon projects.
Usage
neon projects <subcommand> [options]
Subcommand | Description |
---|---|
list | List projects |
create | Create a project |
update | Update a project |
delete | Delete a project |
get | Get a project |
list
This subcommand allows you to list projects that belong to your Neon account, as well as any projects that were shared with you.
Usage
neon projects list [options]
Options
In addition to the Neon CLI global options, the projects
subcommand supports this option:
Option | Description | Type | Required |
---|---|---|---|
--context-file | Context file path and file name | string | |
--org-id | List all projects belonging to the specified organization. If unspecified, personal account projects are listed instead. | string |
Examples
-
List all projects belonging to your personal acccount
neon projects list Projects ββββββββββββββββββββββββββ¬βββββββββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββββββββ β Id β Name β Region Id β Created At β ββββββββββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββββ€ β crimson-voice-12345678 β frontend β aws-us-east-2 β 2024-04-15T11:17:30Z β ββββββββββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββββ€ β calm-thunder-12121212 β backend β aws-us-east-2 β 2024-04-10T15:21:01Z β ββββββββββββββββββββββββββΌβββββββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββββ€ β nameless-hall-87654321 β billing β aws-us-east-2 β 2024-04-10T14:35:17Z β ββββββββββββββββββββββββββ΄βββββββββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββββββββ Shared with you βββββββββββββββββββββ¬βββββββββββββββββββββ¬βββββββββββββββββββ¬βββββββββββββββββββββββ β Id β Name β Region Id β Created At β βββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββΌβββββββββββββββββββββββ€ β noisy-fire-212121 β API β aws-eu-central-1 β 2023-04-22T18:41:13Z β βββββββββββββββββββββ΄βββββββββββββββββββββ΄βββββββββββββββββββ΄βββββββββββββββββββββββ
-
List all projects belonging to the specified organization.
neon projects list --org-id org-xxxx-xxxx Projects βββββββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββ¬βββββββββββββββββββββ¬βββββββββββββββββββββββ β Id β Name β Region Id β Created At β βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββββ€ β bright-moon-12345678 β dev-backend-api β aws-us-east-2 β 2024-07-26T11:43:37Z β βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββββ€ β silent-forest-87654321 β test-integration-service β aws-eu-central-1 β 2024-05-30T22:14:49Z β βββββββββββββββββββββββββββββΌββββββββββββββββββββββββββββΌβββββββββββββββββββββΌβββββββββββββββββββββββ€ β crystal-stream-23456789 β staging-web-app β aws-us-east-2 β 2024-05-17T13:47:35Z β βββββββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββ΄βββββββββββββββββββββ΄βββββββββββββββββββββββ
create
This subcommand allows you to create a Neon project.
Usage
neon projects create [options]
Options
In addition to the Neon CLI global options, the create
subcommand supports these options:
Option | Description | Type | Required |
---|---|---|---|
--context-file | Context file path and file name. | string | |
--name | The project name. The project ID is used if a name is not specified. | string | |
--region-id | The region ID. Possible values: aws-us-west-2 , aws-ap-southeast-1 , aws-ap-southeast-2 , aws-eu-central-1 , aws-us-east-1 , aws-us-east-2 , azure-eastus2 . Defaults to aws-us-east-2 if not specified. | string | |
--org-id | The organization ID where you want this project to be created. If unspecified, the project is created in your personal account. | string | |
--psql | Connect to your new project's database via psql immediately on project creation. | boolean | |
--database | The database name. If not specified, the default database name will be used. | string | |
--role | The role name. If not specified, the default role name will be used. | string | |
--set-context | Set the current context to the new project. | boolean | |
--cu | The compute size for the default branch's primary compute. Could be a fixed size (e.g., "2") or a range delimited by a dash (e.g., "0.5-3"). | string |
note
Neon projects created using the CLI use the default Postgres version, which is Postgres 17. To create a project with a different Postgres version, you can use the Neon Console or Neon API.
Examples
-
Create a project with a user-defined name in a specific region:
neon projects create --name mynewproject --region-id aws-us-west-2 βββββββββββββββββββββ¬βββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββββββββ β Id β Name β Region Id β Created At β βββββββββββββββββββββΌβββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββββ€ β muddy-wood-859533 β mynewproject β aws-us-west-2 β 2023-07-09T17:04:29Z β βββββββββββββββββββββ΄βββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββββββββ ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ β Connection Uri β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€ β postgresql://[user]:[password]@[neon_hostname]/[dbname] β ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
tip
The Neon CLI provides a
neon connection-string
command you can use to extract a connection uri programmatically. See Neon CLI commands β connection-string. -
Create a project with the
--output
format of the command set tojson
. This output format returns all of the project response data, whereas the defaulttable
output format (shown in the preceding example) is limited in the information it can display.neon projects create --output json
Example output
{ "project": { "data_storage_bytes_hour": 0, "data_transfer_bytes": 0, "written_data_bytes": 0, "compute_time_seconds": 0, "active_time_seconds": 0, "cpu_used_sec": 0, "id": "long-wind-77910944", "platform_id": "aws", "region_id": "aws-us-east-2", "name": "long-wind-77910944", "provisioner": "k8s-pod", "default_endpoint_settings": { "autoscaling_limit_min_cu": 1, "autoscaling_limit_max_cu": 1, "suspend_timeout_seconds": 0 }, "pg_version": 17, "proxy_host": "us-east-2.aws.neon.tech", "branch_logical_size_limit": 204800, "branch_logical_size_limit_bytes": 214748364800, "store_passwords": true, "creation_source": "neonctl", "history_retention_seconds": 604800, "created_at": "2023-08-04T16:16:45Z", "updated_at": "2023-08-04T16:16:45Z", "consumption_period_start": "0001-01-01T00:00:00Z", "consumption_period_end": "0001-01-01T00:00:00Z", "owner_id": "e56ad68e-7f2f-4d74-928c-9ea25d7e9864" }, "connection_uris": [ { "connection_uri": "postgresql://alex:AbC123dEf@ep-cool-darkness-123456.us-east-2.aws.neon.tech/dbname", "connection_parameters": { "database": "dbname", "password": "AbC123dEf", "role": "alex", "host": "ep-cool-darkness-123456.us-east-2.aws.neon.tech", "pooler_host": "ep-cool-darkness-123456-pooler.us-east-2.aws.neon.tech" } } ] }
-
Create a project and connect to it with
psql
.neon project create --psql
-
Create a project, connect to it with
psql
, and run an.sql
file.neon project create --psql -- -f dump.sql
-
Create a project, connect to it with
psql
, and run a query.neon project create --psql -- -c "SELECT version()"
-
Create a project and set the Neon CLI project context.
neon project create --psql --set-context
update
This subcommand allows you to update a Neon project.
Usage
neon projects update <id> [options]
The id
is the project ID, which you can obtain by listing your projects or from the Settings page in the Neon Console.
Options
In addition to the Neon CLI global options, the update
subcommand supports this option:
Option | Description | Type | Required |
---|---|---|---|
--context-file | Context file path and file name | string | |
--name | The project name. The value cannot be empty. | string | β |
Examples
Update the project name:
neon projects update muddy-wood-859533 --name dev_project_1
βββββββββββββββββββββ¬ββββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββββββββ
β Id β Name β Region Id β Created At β
βββββββββββββββββββββΌββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββββ€
β muddy-wood-859533 β dev_project_1 β aws-us-west-2 β 2023-07-09T17:04:29Z β
βββββββββββββββββββββ΄ββββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββββββββ
delete
This subcommand allows you to delete a Neon project.
neon projects delete <id> [options]
The id
is the project ID, which you can obtain by listing your projects or from the Settings page in the Neon Console.
Options
Only global options apply.
Example
neon projects delete muddy-wood-859533
βββββββββββββββββββββ¬ββββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββββββββ
β Id β Name β Region Id β Created At β
βββββββββββββββββββββΌββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββββ€
β muddy-wood-859533 β dev_project_1 β aws-us-west-2 β 2023-07-09T17:04:29Z β
βββββββββββββββββββββ΄ββββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββββββββ
Information about the deleted project is displayed. You can verify that the project was deleted by running neon projects list
.
get
This subcommand allows you to retrieve details about a Neon project.
Usage
neon projects get <id> [options]
The id
is the project ID, which you can obtain by listing your projects or from the Settings page in the Neon Console.
Options
In addition to the Neon CLI global options, the delete
subcommand supports this option:
Option | Description | Type | Required |
---|---|---|---|
--context-file | Context file path and file name. | string |
Example
neon projects get muddy-wood-859533
βββββββββββββββββββββ¬ββββββββββββββββ¬ββββββββββββββββ¬βββββββββββββββββββββββ
β Id β Name β Region Id β Created At β
βββββββββββββββββββββΌββββββββββββββββΌββββββββββββββββΌβββββββββββββββββββββββ€
β muddy-wood-859533 β dev_project_1 β aws-us-west-2 β 2023-07-09T17:04:29Z β
βββββββββββββββββββββ΄ββββββββββββββββ΄ββββββββββββββββ΄βββββββββββββββββββββββ
Need help?
Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more details, see Getting Support.