Skip to main content

Running the CLI

The twenty CLI connects to Twenty workspaces from your terminal. Use it to inspect metadata, read records, send API requests, and create, sync and debug apps. The CLI itself requires Node.js 24.5+. App development also needs a Node version supported by the installed SDK, see Quick Start. Run any command through npx, without a global installation:
Or install it once globally and call twenty directly:
The examples below use twenty. Replace twenty with npx twenty@latest if you did not install it globally. Run twenty commands for the full command list and twenty <command> --help for the options of one command. Every command that talks to a workspace accepts --remote <name> to target a saved connection other than the default one, and --json for structured output (streaming commands such as app dev and app logs use --format ndjson instead).

Connecting to a workspace

Sign in with your browser. --use makes this connection the default one:
Use your workspace’s address, or the server’s address for a local setup: http://localhost:2020 for the local development environment, http://localhost:3000 for a source checkout. You can copy the exact command from Settings > Developers > CLI. Browser sign-in needs Twenty 2.42 or later. Keep several connections by naming them:
In CI or scripts, pipe an API key instead of signing in with the browser:
You can also set TWENTY_API_URL and TWENTY_API_KEY for a single run without saving anything. Saved connections live in ~/.twenty/config.json. Commands select a workspace in this order:
  1. An explicit --remote <name>, which overrides the target environment variables.
  2. TWENTY_REMOTE, or the pair TWENTY_API_URL and TWENTY_API_KEY. Do not combine these two methods.
  3. The saved default remote.
auth login --name <name> saves a connection but keeps an existing default. Add --use, or run twenty remote use <name>, to change the default.

Behind an authenticating proxy

If an identity-aware proxy such as Cloudflare Access, Google IAP, Pomerium or oauth2-proxy sits in front of the server, commands fail with PROXY_AUTH_REQUIRED. Give the CLI the proxy’s credentials as headers. Use a command that prints fresh ones, or fixed values for a service token:
Both are saved on the connection. The command prints one Name: value line per header. The CLI runs it again when the proxy rejects the headers, and PROXY_HEADERS_FAILED reports a command that fails. In CI, set TWENTY_PROXY_HEADERS (one Name: value per line) or TWENTY_PROXY_HEADER_COMMAND instead. Proxy headers are only sent to the connection’s API URL and cannot replace Authorization. See the CLI reference for every option.

Exploring your data

Object names are exact API names, singular or plural (company or companies). Raw API writes run without a confirmation step, and your permissions in the workspace still apply.

Building an app

  • app init writes a new project from the template. It does not install dependencies or contact a workspace.
  • app apply --create builds the app, registers it in the workspace, installs it, syncs its metadata, then waits up to two minutes for the background operations that sync started (indexes, foreign keys, computed values) to finish.
  • app dev watches your source and syncs every successful build.
Existing external local files use native filesystem events. Missing or deleted paths use recovery checks once per second until native watching can resume. Home and temporary directory roots and their ancestors are excluded from automatic external directory observation. If WATCH_SCOPE_LIMITED appears for a missing import, fix the import, then edit an app file or restart app dev. Run twenty app dev --verbose to see watched and excluded paths after the first build attempt and whenever they change. Add --format ndjson for structured watch-scope progress events. Other app commands: Definitions missing from your source are deleted from the workspace by default. Pass --no-prune to keep them. The workspace Custom application keeps them unless you pass --prune. Deleting objects or fields also deletes their data, so it requires confirmation. See Syncing & recovery for details. Outside the workspace Custom application, plan, apply, dev and publish refuse roles that workspace members or API keys can hold, and field or row-level permissions. See Roles outside the workspace Custom application.

Executing functions

Run a deployed logic function without triggering it through a route, a cron or a database event. Sync your local changes with app apply or app dev first.
Executing functions requires a browser sign-in and the Workspace Apps and Workflows permissions. API keys cannot execute them.

Watching function logs

Stream the output of your app’s logic functions as executions finish:
It only shows new executions, not past ones.

Uninstalling an app

This runs the app’s uninstall hook and deletes everything it owns, including its objects, fields and their data. The app stays registered, so twenty app apply can install it again. While a background data model operation is still running in the workspace, the uninstall is refused before anything runs or is deleted (DEFERRED_WORKSPACE_MIGRATION_ACTIONS_IN_PROGRESS). Run it again once the operation finishes.

Diagnosing problems

doctor checks your Node version, which twenty binary is on your PATH, your saved connections and the app SDK, then reports what to fix.

Scripts and tests

Build output belongs to the CLI. Do not read .twenty/output/manifest.json or import internal build code; read data.manifest from twenty app build --json.

Full reference

The command reference covers every flag, permission, output format and exit code.

Export workspace records

data export requires the workspace’s Export CSV permission. It follows the server’s export progress, then streams the CSV to --output. Record and field permissions are enforced by the server. An app project is not required; select a saved connection with --remote or use the usual environment credentials. The output file appears only after a successful download. Existing files are kept unless you pass --force. Downloads are limited to 1 GiB and 15 minutes. If interrupted, run the export again; the download link cannot be reused. --json reports the export ID, path, size and duration; --format ndjson also streams progress. The CSV itself is written only to the named file.