Neon is expanding into a backend: Object Storage, Functions, and AI Gateway now in beta
/APIs & SDKs/Functions, storage and data/data-api

Neon CLI command: data-api

Provision and manage the Neon Data API from the CLI

The data-api command provisions and manages the Neon Data API for a database. For Console-based management, see Manage Data API.

Requires neon 2.22.2 or later. Check your version with neon --version.

Subcommands: create, delete, get, refresh-schema, update

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

Settings flags

The create and update subcommands share a set of settings flags that configure how the Data API serves your database:

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

neon data-api create

Provisions the Neon Data API for a database.

neon data-api create [options]
OptionDescriptionTypeDefaultRequired
--add-default-grantsGrant all permissions on tables in the public schema to authenticated usersbooleanNo
--auth-providerAuthentication provider Possible values: neon_auth, externalstringNo
--db-aggregates-enabledEnable aggregate functions in queriesbooleanNo
--db-anon-roleDatabase role used for anonymous (unauthenticated) requestsstringNo
--db-extra-search-pathExtra schemas appended to the search pathstringNo
--db-max-rowsMaximum number of rows returned by a single requestnumberNo
--db-schemasComma-separated list of schemas exposed via the Data APIstringNo
--jwks-urlURL that lists the JWKS (used with external auth)stringNo
--jwt-audienceExpected JWT audience claimstringNo
--jwt-cache-max-lifetimeMaximum JWT cache lifetime in secondsnumberNo
--jwt-role-claim-keyJWT claim path used to extract the rolestringNo
--openapi-modeOpenAPI mode Possible values: ignore-privileges, disabledstringNo
--provider-nameName of the auth provider (e.g. Clerk, Stytch, Auth0)stringNo
--server-cors-allowed-originsCORS allowed originsstringNo
--server-timing-enabledEnable Server-Timing response headersbooleanNo
--skip-auth-schemaSkip creating the auth schema and RLS functionsbooleanNo
--branchBranch ID or namestringNo
--databaseDatabase namestringNo
--project-idProject IDstringNo

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

Provision the Data API with Managed Better Auth:

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

neon data-api get

Shows the Neon Data API status and settings.

neon data-api get [options]
OptionDescriptionTypeDefaultRequired
--branchBranch ID or namestringNo
--databaseDatabase namestringNo
--project-idProject IDstringNo
neon data-api get --database neondb

neon data-api update

Updates Neon Data API settings. By default, the flags you provide are merged with the current settings. Pass --replace to overwrite all settings with only the flags you provide.

neon data-api update [options]
OptionDescriptionTypeDefaultRequired
--db-aggregates-enabledEnable aggregate functions in queriesbooleanNo
--db-anon-roleDatabase role used for anonymous (unauthenticated) requestsstringNo
--db-extra-search-pathExtra schemas appended to the search pathstringNo
--db-max-rowsMaximum number of rows returned by a single requestnumberNo
--db-schemasComma-separated list of schemas exposed via the Data APIstringNo
--jwt-cache-max-lifetimeMaximum JWT cache lifetime in secondsnumberNo
--jwt-role-claim-keyJWT claim path used to extract the rolestringNo
--openapi-modeOpenAPI mode Possible values: ignore-privileges, disabledstringNo
--replaceReplace settings with only the flags provided. Omitted settings revert to server defaults.booleanfalseNo
--server-cors-allowed-originsCORS allowed originsstringNo
--server-timing-enabledEnable Server-Timing response headersbooleanNo
--branchBranch ID or namestringNo
--databaseDatabase namestringNo
--project-idProject IDstringNo

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

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

neon data-api refresh-schema

Refreshes the Data API schema cache without changing settings.

neon data-api refresh-schema [options]
OptionDescriptionTypeDefaultRequired
--branchBranch ID or namestringNo
--databaseDatabase namestringNo
--project-idProject IDstringNo
neon data-api refresh-schema --database neondb

neon data-api delete

Deletes the Neon Data API for a database.

neon data-api delete [options]
OptionDescriptionTypeDefaultRequired
--branchBranch ID or namestringNo
--databaseDatabase namestringNo
--project-idProject IDstringNo
neon data-api delete --database neondb
Was this page helpful?
Edit on GitHub

On this page

Copy neon init command