-h, --help.
xata branch list— List all branchesxata branch describe— Describe a branchxata branch create— Create a new branchxata branch delete— Delete a branchxata branch logs— Retrieve the PostgreSQL logs of a branchxata branch url— Print URL (connection string) for a branchxata branch checkout— Check out a branch in this folderxata branch tree— List all branches as a treexata branch get— Get a field from a branch descriptionxata branch metrics— Show CPU, memory and disk usage for a branchxata branch set— Set a field value for a branchxata branch rotate-password— Rotate the database password for a branchxata branch wait-ready— Wait for a branch to be readyxata branch query-insights— Inspect query statistics and active queries for a branchxata branch query-insights list— List historical query statistics for a branch, by total execution timexata branch query-insights show— Show full query statistics for a query IDxata branch query-insights active— List currently running queries for a branchxata branch query-insights enable— Enable pg_stat_statements for query insights on a branchxata branch query-insights reset— Reset accumulated query statistics for a branch
list
List all branchesOutput in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
xata branch ls
describe
Describe a branchOutput in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
xata branch view, xata branch show
create
Create a new branch A branch is a running Postgres database that starts as a copy of its parent. It takes a moment to come up, soxata branch wait-ready is what to run before connecting to it. It is checked out afterwards when this folder already has an organization and a project to work from.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
delete
Delete a branch The branch checked out in this folder cannot be deleted, and outside an interactive terminal the confirmation has to come from--yes.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
logs
Retrieve the PostgreSQL logs of a branch Reads the logs of every instance of the branch, the primary and any replicas, which is where slow queries, connection issues and replication problems show up. Requires thelogs:read scope on the API key. Of the output formats, raw prints <timestamp> [<level> <instanceID> <process>] <message> per line, json a single array, ndjson one object per line for streaming into another process, and csv the columns timestamp,level,instanceID,process,message. Follow mode polls every 2 seconds with a 5 second overlap and de-duplicates entries. Logs can contain connection strings and other credentials, see https://xata.io/docs/platform/logs for what is redacted.
Case-insensitive substring search in the log message body. For regex filtering, pipe raw output to rg/grep, e.g. xata branch logs —output raw | rg ‘timeout|deadlock’
Start time as YYYY-MM-DDTHH:mm:ss.sssZ or relative duration, e.g. 15m, 1h, 7d. Defaults to 1h ago.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
url
Print URL (connection string) for a branch Reads the connection details from the credentials endpoint, so an API key needs thecredentials:read scope, see https://xata.io/docs/cli#required-scopes.
Connection type: primary (direct access to the primary), primary-or-replica (routed access to primary or replicas), replica (read-only access to replicas only, requires at least one replica), pooler (pooled access to the primary, recommended for serverless and high-concurrency workloads)
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
xata branch connection-string
checkout
Check out a branch in this folder Writes the branch to.xata/ in this folder, so later commands run against it without being told which branch to use.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
tree
List all branches as a treeOutput in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
xata branch topology
get
Get a field from a branch description Run it without a field to list the fields the description holds.Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
metrics
Show CPU, memory and disk usage for a branch Reports the metrics of every instance of the branch, the primary and any replicas, as a snapshot or continuously with —watch.Output format. Defaults to table, or json when an AI agent runs the command.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
set
Set a field value for a branch Thepostgres-version field upgrades PostgreSQL, and only accepts compatible upgrades within the same major version and offering type, see https://xata.io/docs/platform/branch#upgrading-postgresql-versions.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
The field to set: name, description, replicas, instance-type, storage, hibernate, scale-to-zero, inactivity-period or postgres-version
rotate-password
Rotate the database password for a branch Reads the current username from the credentials endpoint, so an API key needs thecredentials:read scope, see https://xata.io/docs/cli#required-scopes.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
wait-ready
Wait for a branch to be ready Blocks until the branch is healthy, which is what a script needs after creating one or after a change that restarts it. A hibernated branch stays hibernated unless--wake is passed.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
query-insights
Inspect query statistics and active queries for a branch Which statements are slow, which are expensive, and what is running right now. Historical statistics come frompg_stat_statements, and the queries running at this moment from pg_stat_activity. Running xata branch qi without a subcommand is the same as xata branch qi list. Except for active, which reads pg_stat_activity, these commands need pg_stat_statements loaded: run xata branch query-insights enable <branch> and then wait for the restart with xata branch wait-ready <branch> --wake. Unlike logs and metrics, which go through the API, these commands open a direct PostgreSQL connection: they cannot run against a branch that is hibernated or still provisioning, and an API key needs the credentials:read scope. The console reads the same pg_stat_statements data, see https://xata.io/docs/platform/query-insights.
Aliases: xata branch qi
query-insights list
List historical query statistics for a branch, by total execution time In table output a leading! marks a row worth a look, a slow mean, spikes far above it, a low cache hit rate, heavy temporary file use or a very large row count, and the command prints the show command for each flagged query. Below the table it prints how many queries are being shown and, when more remain, the list command that fetches the next page. Both json and ndjson emit { "total", "limit", "offset", "queries" }, with the statements under queries.
total-time | mean-time | min-time | max-time | stddev-time | calls | rows | shared-hit | shared-read | shared-dirtied | shared-written | local-hit | local-read | local-dirtied | local-written | temp-read | temp-written | database | user
default:"total-time"
Sort by a query insight metric or dimension
Output format. Defaults to table, or json when an AI agent runs the command.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
xata branch query-insights ls
query-insights show
Show full query statistics for a query ID A query ID is not unique on its own, the same normalized statement is recorded once per database and role that ran it. When the ID matches more than one row the command exits non-zero, re-run it with--db and --role. Human output ends with the potential issues found for the query.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
xata branch query-insights get
query-insights active
List currently running queries for a branch Readspg_stat_activity, so it works without pg_stat_statements being loaded. The columns are PID, Age, State, Wait, DB, User, Client and Query.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
query-insights enable
Enable pg_stat_statements for query insights on a branch Addspg_stat_statements to the preloaded libraries, which restarts the branch, and creates the extension. Run it, wait for the branch with xata branch wait-ready <branch> --wake, then run it again to create the extension. Operations that rebuild a branch, such as a migration into it, can drop the extension, so run this again if query insights stop returning rows. The same can be done from the console, by adding it to the preloaded libraries in the branch settings, see https://xata.io/docs/platform/extensions.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.
query-insights reset
Reset accumulated query statistics for a branch Callspg_stat_statements_reset(), which requires elevated privileges.
Output in JSON format when the command supports it. Defaults to on when an AI agent runs the command.