Skip to main content

Getting Started

Make sure to first set up your PlanetScale developer environment. Once you’ve installed the pscale CLI, you can interact with PlanetScale and manage your databases straight from the command line.

The traffic-control command

Manage Database Traffic Control budgets and rules for a branch. This command is only supported for Postgres databases. Usage:
pscale traffic-control [command]

Available sub-commands

Sub-commandDescription
budgetManage traffic budgets
ruleManage traffic rules

Available flags

FlagDescription
-h, --helpView help for traffic-control command
--org stringThe organization for the current user

Global flags

CommandDescription
--api-token <TOKEN>The API token to use for authenticating against the PlanetScale API.
--api-url <URL>The base URL for the PlanetScale API. Default is https://api.planetscale.com/.
--config <CONFIG_FILE>Config file. Default is $HOME/.config/planetscale/pscale.yml.
--debugEnable debug mode.
-f, --format <FORMAT>Show output in a specific format. Possible values: human (default), json, csv.
--no-colorDisable color output.
--service-token <TOKEN>The service token for authenticating.
--service-token-id <TOKEN_ID>The service token ID for authenticating.

The budget sub-command

Manage traffic budgets. Usage:
pscale traffic-control budget [command]

Available sub-commands

Sub-commandDescription
createCreate a traffic budget
deleteDelete a traffic budget
showShow a traffic budget
updateUpdate a traffic budget

The budget create sub-command

Create a traffic budget. Usage:
pscale traffic-control budget create <database> <branch> [flags]
Available flags:
FlagDescription
--name stringName of the traffic budget (required)
--mode stringMode of the budget: enforce, warn, or off (default warn)
--rate intRate at which capacity refills, as a percentage of server resources (0-100). Unlimited when not set.
--capacity intMaximum capacity that can be banked (0-6000). Unlimited when not set.
--burst intMaximum capacity a single query can consume (0-6000). Unlimited when not set.
--concurrency intPercentage of available worker processes (0-100). Unlimited when not set.

The budget update sub-command

Update a traffic budget. Usage:
pscale traffic-control budget update <database> <branch> <budget-id> [flags]
A budget’s <budget-id> can be retrieved by running the show, create, or list commands. Available flags: Same flags as budget create.

The budget show sub-command

Show a traffic budget. Usage:
pscale traffic-control budget show <database> <branch> <budget-id> [flags]

The budget delete sub-command

Delete a traffic budget. Usage:
pscale traffic-control budget delete <database> <branch> <budget-id> [flags]
Available flags:
FlagDescription
--forceDelete a budget without confirmation
Aliases: delete, rm

The rule sub-command

Manage traffic rules. Usage:
pscale traffic-control rule [command]

Available sub-commands

Sub-commandDescription
createCreate a traffic rule on a budget
deleteDelete a traffic rule from a budget

The rule create sub-command

Create a traffic rule on a budget. Usage:
pscale traffic-control rule create <database> <branch> <budget-id> [flags]
This command adds a rule to the budget. Rules are combined via OR, tags within a rule are combined via AND. Create multiple rules to get the desired AND/OR behavior. Available flags:
FlagDescription
--fingerprint stringSQL fingerprint to match
--keyspace stringKeyspace to match
--kind stringKind of rule (default match)
--tag stringArrayTag in the format key=<key>,value=<value>,source=<source> (repeatable)

The rule delete sub-command

Delete a traffic rule from a budget. Usage:
pscale traffic-control rule delete <database> <branch> <budget-id> <rule-id> [flags]
Available flags:
FlagDescription
--forceDelete a rule without confirmation
Aliases: delete, rm

Need help?

Get help from the PlanetScale Support team, or join our Discord community to see how others are using PlanetScale.