Skip to content

PlanetScale CLI commands - service-token

Use the PlanetScale CLI to create development branches, open deploy requests, and make non-blocking schema changes directly from your terminal.

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 service-token command

This command allows you to create, list, and manage access for service tokens.

Usage:

Copied
pscale service-token <SUB-COMMAND> <FLAG>

Available sub-commands

Sub-commandSub-command flagsDescription
add-access <TOKEN_ID> <PERMISSION> <PERMISSION>--database <DATABASE_NAME>Add individual permissions to the specified service token in the organization
createCreate a service token for the organization
delete <TOKEN_ID>Delete an entire service token in an organization
delete-access <TOKEN_ID> <PERMISSION> <PERMISSION>--database <DATABASE_NAME>Delete individual permissions granted to a service token in the organization
listList the IDs of

The value <PASSWORD_ID> represents the ID number of the set of credentials. To find all available credentials and their IDs, run pscale list <DATABASE_NAME> <BRANCH_NAME>.

Sub-command flag descriptions

Some of the sub-commands have additional flags unique to the sub-command. This section covers what each of those does. See the above table for which context.

Sub-command flagDescriptionApplicable sub-commands
--database <DATABASE_NAME>The database this project is using.add-access, delete-access

Available flags

FlagDescription
-h, --helpView help for service-token command
--org <ORGANIZATION_NAME>The 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.

Examples

The service-token command with add-access sub-command and --database flag

Command:

Copied
pscale service-token add-access <TOKEN_ID> read_branch delete_branch create_branch --database <DATABASE_NAME_2>

This will add the following permissions to the specified access token: read_branch, delete_branch, create_branch. The output will show the updated permissions on all databases.

You can find a list of all permissions in our Access control doc.

Output:

DATABASEACCESSES
DATABASE_NAMEapprove_deploy_request, connect_branch, connect_production_branch, create_branch, create_comment, create_deploy_request, delete_branch, read_branch, read_comment, read_deploy_request
DATABASE_NAME_2read_branch, delete_branch, create_branch

Need help?

Get help from PlanetScale's support team, or join our GitHub Discussion board to see how others are using PlanetScale.

Was this page useful?
Last updated on May 3, 2022
Help us improve this page
PrivacyTerms© 2022 PlanetScale Inc.