All paid plans now include 5x more free data transfer: 500 GB per month, up from 100 GB. Read the details here.
/API, CLI & SDKs/data-api

Neon CLI command: data-api

Provision and manage the Neon Data API from the CLI

Before you begin

  • Before running the data-api command, ensure that you have installed the Neon CLI.
  • The data-api command requires neonctl 2.22.2 or later. Check your version with neon --version.
  • 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 an overview of the Neon Data API, see Data API. For Console-based management, see Manage Data API.

Thedata-apicommand

The data-api command lets you provision and manage the Neon Data API for a database from the terminal.

Usage

neon data-api <subcommand> [options]
SubcommandDescription
createProvision the Neon Data API for a database
getShow the Neon Data API status and settings
updateUpdate Neon Data API settings
refresh-schemaRefresh the Data API schema cache without changing settings
deleteTear down the Neon Data API for a database

Shared options

These options apply to all data-api subcommands:

OptionDescriptionType
--project-idProject IDstring
--branchBranch ID or namestring
--databaseDatabase namestring
--context-fileContext file path and file namestring

If --project-id, --branch, or --database are omitted, the CLI resolves them from your context file or prompts when only one option is available.

createoptions

OptionDescriptionType
--auth-providerAuthentication provider. Choices: neon_auth, externalstring
--jwks-urlURL that lists the JWKS (used with external auth)string
--provider-nameName of the auth provider (for example, Clerk, Stytch, Auth0)string
--jwt-audienceExpected JWT audience claimstring
--add-default-grantsGrant all permissions on tables in the public schema to authenticated usersboolean
--skip-auth-schemaSkip creating the auth schema and RLS functionsboolean

create also accepts settings flags to configure the Data API at provision time.

updateoptions

OptionDescriptionType
--replaceReplace settings with only the flags provided. Omitted settings revert to server defaults. The default is false (merge with current).boolean

update requires at least one settings flag, or use refresh-schema to refresh the schema cache without changing settings.

Settings flags

These flags are supported by create and update:

FlagDescriptionType
--db-aggregates-enabledEnable aggregate functions in queriesboolean
--db-anon-roleDatabase role used for anonymous (unauthenticated) requestsstring
--db-extra-search-pathExtra schemas appended to the search pathstring
--db-max-rowsMaximum number of rows returned by a single requestnumber
--db-schemasComma-separated list of schemas exposed via the Data APIstring
--jwt-role-claim-keyJWT claim path used to extract the rolestring
--jwt-cache-max-lifetimeMaximum JWT cache lifetime in secondsnumber
--openapi-modeOpenAPI mode. Choices: ignore-privileges, disabledstring
--server-cors-allowed-originsCORS allowed originsstring
--server-timing-enabledEnable Server-Timing response headersboolean

Examples

Provision the Data API with Neon Auth:

neon data-api create --database neondb --auth-provider neon_auth

Show current Data API status:

neon data-api get --database neondb

Update the maximum rows setting:

neon data-api update --database neondb --db-max-rows 1000

Refresh the schema cache:

neon data-api refresh-schema --database neondb

Delete the Data API for a database:

neon data-api delete --database neondb

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. For paid plan support options, see Support.

Was this page helpful?
Edit on GitHub

On this page

Copy neon init command