cli

module
v0.23.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2026 License: MPL-2.0

README

Zeabur CLI

Zeabur's official command line tool

Note: Zeabur CLI is currently in beta, and we are still working on it. If you have any questions or suggestions, please feel free to contact us.

How cool it is

  1. Manage your Zeabur resources with CLI
  2. Login with browser or token
  3. Intuitive and easy to use
  4. The design of the context makes it easier for you to manage services.
  5. The seamless integration of interactive and non-interactive modes.

Quick Start

1. Install

No need to install, you can use it directly with npx. Make sure you have Node.js installed.

2. Login

If you can open the browser:

npx zeabur auth login

Or you can use token to login:

npx zeabur auth login --token <your-token>

Zeabur CLI will open a browser window and ask you to login with your Zeabur account.

asciicast

# list all projects
npx zeabur project ls

# set project context, the following commands will use this project context
# you can use arrow keys to select the project
npx zeabur context set project

# list all services in the project
npx zeabur service ls

# set service context(optional)
npx zeabur context set service

# set environment context(optional)
npx zeabur context set env

# restart the service
npx zeabur service restart

# get the latest deployment info
npx zeabur deployment get

# get the latest deployment log(runtime)
npx zeabur deployment log -t=runtime

# get the latest deployment log(build)
npx zeabur deployment log -t=build
4. Manage your resources(Non-interactive mode)

Non-interactive mode is useful when you want to use Zeabur CLI in a script(such as CI/CD pipeline, etc.)

Note: you can add -i=false to all commands to disable interactive mode. In fact, if the parameters are complete, it's same whether you use interactive mode or not.

# list all projects
npx zeabur project ls -i=false

# set project context, the following commands will use this project context
npx zeabur context set project --name <project-name>
# or you can use project id
# npx zeabur context set project --id <project-id>

# list all services in the project
npx zeabur service ls

# set service context(optional)
npx zeabur context set service --name <service-name>
# or you can use service id
# npx zeabur context set service --id <service-id>

# set environment context(optional)(only --id is supported)
npx zeabur context set env --id <env-id>

# restart the service
# if service context is set, you can omit the service name; so does environment context
npx zeabur service restart --env-id <env-id> --service-name <service-name>
# or you can use service id
# npx zeabur service restart --env-id <env-id> --service-id <service-id>

# get the latest deployment info(if contexts are set, you can omit the parameters)
npx zeabur deployment get --env-id <env-id> --service-name <service-name>
# or you can use service id
# npx zeabur deployment get --env-id <env-id> --service-id <service-id>

# get the latest deployment log(runtime)(service id is also supported)
npx zeabur deployment log -t=runtime --env-id <env-id> --service-name <service-name>
# get the latest deployment log(build)(service id is also supported)
npx zeabur deployment log -t=build --env-id <env-id> --service-name <service-name>
  1. More commands
npx zeabur <command> --help

Workspaces (personal / team)

By default, the CLI acts under the personal workspace — the account that logged in. To list or create projects under a team you belong to, switch the workspace:

# show your personal workspace + all teams you belong to, with your role per team
npx zeabur workspace list

# switch to a team — pass either the team name OR its 24-char ObjectID.
# A 24-char hex value is always interpreted as an ID; anything else is
# looked up by name. If multiple teams share a name the CLI errors out and
# prints the per-candidate `workspace switch <id>` invocation so you can
# pick by ID (team names are unconstrained, so duplicates are possible).
npx zeabur workspace switch acme

# show the workspace the CLI is currently using
npx zeabur workspace current

# return to the personal workspace
npx zeabur workspace clear

Switching a workspace clears the pinned project / environment / service context, because resource IDs do not overlap between workspaces.

The workspace only affects directory-level commands (project list, project create, deploy without a linked project). Commands that take a specific service or deployment ID use that resource's own owner and are workspace-independent — your team's service restart works the same regardless of which workspace is active.

For one-off commands that should run under a different workspace without switching the persisted state, use the --workspace flag:

# list projects in the "acme" team without switching workspaces
npx zeabur --workspace acme project list

switch personal is not a way to return to personal — it always looks for a team literally named personal (team names are unconstrained). Use workspace clear to go back.

Raw GraphQL requests

zeabur api graphql sends any GraphQL query to the Zeabur API with the credentials of the logged-in user and prints the raw JSON response — useful for fields that no dedicated command exposes yet, and for scripts or coding agents that should never handle the token themselves.

# the query is passed as the "query" field
npx zeabur api graphql -f query='query { me { _id username } }'

# every other field becomes a variable: -f adds a string, -F adds a typed value
# (true / false / null / integers; @file or @- reads the value from a file / stdin)
npx zeabur api graphql -f query='query($id: ObjectID!) { project(_id: $id) { name } }' -F id=<project-id>
npx zeabur api graphql -F query=@query.graphql -F limit=10

# or pass a complete JSON request body
echo '{"query": "query { me { _id } }"}' | npx zeabur api graphql --input -

The command exits non-zero when the request fails or the response contains GraphQL errors; the response body is still printed. The request is sent as-is — --workspace and the saved context do not rewrite it, so pass team or project IDs as variables.

Development Guide

Development Guide

Acknowledgements

  1. GitHub
    • GitHub provides us a place to store the source code of this project and running the CI/CD pipeline.
    • cli/cli provides significant inspiration for the organizational structure of this project.
    • cli/oauth we write our own CLI browser OAuth flow based on this project.

Directories

Path Synopsis
Package main provides the entry point of the cli
Package main provides the entry point of the cli
internal
cmd/api
Package api provides the `zeabur api` command for raw Zeabur API requests.
Package api provides the `zeabur api` command for raw Zeabur API requests.
cmd/api/graphql
Package graphql provides `zeabur api graphql`, which sends an arbitrary GraphQL request to the Zeabur API using the CLI's stored credentials.
Package graphql provides `zeabur api graphql`, which sends an arbitrary GraphQL request to the Zeabur API using the CLI's stored credentials.
cmd/auth
Package auth contains the cmd for managing authentication
Package auth contains the cmd for managing authentication
cmd/auth/login
Package login provides the login command
Package login provides the login command
cmd/completion
Package completion contains the cmd for generating shell completion scripts
Package completion contains the cmd for generating shell completion scripts
cmd/context
Package context contains the cmd for managing contexts
Package context contains the cmd for managing contexts
cmd/context/set
Package set is the subcommand to set the context for the CLI.
Package set is the subcommand to set the context for the CLI.
cmd/profile
Package profile contains the cmd for managing profile
Package profile contains the cmd for managing profile
cmd/project
Package project contains the cmd for managing projects
Package project contains the cmd for managing projects
cmd/root
Package root provides the root command
Package root provides the root command
cmd/server/exec
Package exec implements `zeabur server exec`: run a command on a dedicated server over SSH and stream its output.
Package exec implements `zeabur server exec`: run a command on a dedicated server over SSH and stream its output.
cmd/service
Package service provides the entry point of the service command
Package service provides the entry point of the service command
cmd/version
Package version contains the cmd for managing the
Package version contains the cmd for managing the
cmd/workspace
Package workspace contains the `zeabur workspace` command group, which drives the personal-vs-team-workspace switcher the CLI uses for directory-level operations (project list / create, deploy with no linked project).
Package workspace contains the `zeabur workspace` command group, which drives the personal-vs-team-workspace switcher the CLI uses for directory-level operations (project list / create, deploy with no linked project).
cmd/workspace/clear
Package clear implements `zeabur workspace clear`.
Package clear implements `zeabur workspace clear`.
cmd/workspace/current
Package current implements `zeabur workspace current`.
Package current implements `zeabur workspace current`.
cmd/workspace/list
Package list implements `zeabur workspace list`.
Package list implements `zeabur workspace list`.
cmd/workspace/switch
Package switchcmd implements `zeabur workspace switch <name|id>`.
Package switchcmd implements `zeabur workspace switch <name|id>`.
cmdutil
Package cmdutil provides utilities for working with cobra commands
Package cmdutil provides utilities for working with cobra commands
pkg
api
Package api provides a client for the Zeabur API.
Package api provides a client for the Zeabur API.
auth
Package auth implements the authentication flow for the CLI
Package auth implements the authentication flow for the CLI
config
Package config provides the config of cli
Package config provides the config of cli
log
Package log contains the loggers for the CLI
Package log contains the loggers for the CLI
model
Package model provides the models for the Zeabur API.
Package model provides the models for the Zeabur API.
prompt
Package prompt provides a prompter interface for UI interactions
Package prompt provides a prompter interface for UI interactions
zcontext
Package zcontext is used to store the context information for the application.
Package zcontext is used to store the context information for the application.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL