clickhousectl, alias chctl) manages ClickHouse Cloud from a terminal, a script or a coding agent. This page covers the Cloud side of the CLI. For every command group, local development and the full behaviour, see the clickhousectl reference.
What you can manage
Theclickhousectl cloud commands cover:
- Services: create, scale, start and stop ClickHouse Cloud services, protect them from deletion, write their connection settings to a
.envfile, and run SQL against them over the Query API or in an interactiveclickhouse clientsession. - Managed Postgres: create Postgres services, read replicas and point-in-time restores, and change their configuration.
- ClickPipes: ingest from object storage, Kafka, Kinesis, Pub/Sub, Postgres, MySQL, MongoDB and BigQuery.
- ClickStack: manage sources, dashboards, alerts, webhooks, saved searches and roles on a Self-managed ClickHouse Observability service.
- User-defined functions: test executable UDFs locally, then deploy them to a Cloud service.
- Backups: list backups, change the backup schedule and restore a backup into a new service.
- Organization access: organizations, members, invitations, API keys and the activity log.
clickhousectl cloud clickhouse, or cloud ch for short. Run clickhousectl cloud <command> --help for the flags of any command and the API key permissions it needs.
Installation
~/.local/bin/clickhousectl and a chctl alias. Make sure ~/.local/bin is on your PATH. For npm, pip, uv and the other install methods, see Installation.
Authentication
Browser OAuth login is read-only. Creating or changing resources needs an API key with a role that allows the change.clickhousectl cloud auth whoami. If you belong to several organizations, add --org-id <org-id> (or --org-name <name>) to Cloud commands. In CI, set CLICKHOUSE_CLOUD_API_KEY and CLICKHOUSE_CLOUD_API_SECRET instead of logging in. See Authentication for credential precedence and logout.
Examples
Create and query a service
clickhousectl cloud clickhouse get "$CH_ID" until state is running. For an existing service, clickhousectl cloud clickhouse dotenv "$CH_ID" --local writes the same settings to .env.local without a password. To guard a production service, turn on deletion protection with clickhouse update "$CH_ID" --deletion-protection true; clickhouse delete then refuses it until you set --deletion-protection false.
With an API key, clickhouse query adds your key to the service’s Query API endpoint if it isn’t bound yet, creating the endpoint if needed; no new key is created. Pass --no-auto-enable to fail instead. A read-only key can’t bind itself, so bind it once with a key that has write access. With OAuth, clickhouse query runs read-only SELECT statements. The Query API times out after about 30 seconds and runs one statement per request, so use cloud clickhouse client for long queries, scripts and bulk loads. It opens clickhouse client over native TLS and signs you in through a browser as your Cloud user, with no service password. It needs ClickHouse 25.12 or newer installed locally (clickhousectl local install latest) and a person at the browser.
Create a Managed Postgres service
create returns the password and connection string, so save them. Omitting --ip-allow opens ports 5432 and 6432 to all addresses. Wait for state to be running, then connect with psql using the CA certificate.
Inspect ClickPipes, ClickStack and backups
Deploy a user-defined function
clickhousectl local udf deploy my_udf against a local server.
JSON output and coding agents
Cloud commands accept--json, and the CLI selects JSON automatically when it detects a coding agent. cloud clickhouse query then defaults to JSONEachRow, so scripts that parse its output should pass --format, for example --format TabSeparated. See JSON output and Exit codes. Install the ClickHouse agent skills with clickhousectl skills.
Learn more
- clickhousectl reference: every command group, local development, skills, self-update and telemetry.
- Repository guides:
- Repository references: authentication and access, SQL and the Query API, ClickPipe configuration and automation and output contracts.