CLI reference
Tokens CLI command reference
Create, inspect and manage tokens
npx sanity tokens --help
pnpm dlx sanity tokens --help
yarn dlx sanity tokens --help
bunx sanity tokens --help
Commands
add
USAGE
$ sanity tokens add [LABEL] [-p <id>] [--yes] [--json] [--role viewer]
ARGUMENTS
[LABEL] Label for the new token
FLAGS
-y, --yes Skip prompts and use defaults (unattended mode)
--json Output as JSON
--role=viewer Role to assign to the token
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to add token to (overrides CLI configuration)
DESCRIPTION
Create a new API token for this project
EXAMPLES
Create a token with a label
$ sanity tokens add "My API Token"
Create a token with editor role
$ sanity tokens add "My API Token" --role=editor
Create a token in unattended mode
$ sanity tokens add "CI Token" --role=editor --yes
Output token information as JSON
$ sanity tokens add "API Token" --json
Create a token for a specific project
$ sanity tokens add "My Token" --project-id abc123 --role=editordelete
USAGE
$ sanity tokens delete [TOKENID] [-p <id>] [--yes]
ARGUMENTS
[TOKENID] Token ID to delete (will prompt if not provided)
FLAGS
--yes Skip confirmation prompt (unattended mode)
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to delete token from (overrides CLI configuration)
DESCRIPTION
Delete an API token from this project
EXAMPLES
Interactively select and delete a token
$ sanity tokens delete
Delete a specific token by ID
$ sanity tokens delete silJ2lFmK6dONB
Delete a specific token without confirmation prompt
$ sanity tokens delete silJ2lFmK6dONB --yes
Delete a token from a specific project
$ sanity tokens delete --project-id abc123list
USAGE
$ sanity tokens list [-p <id>] [--json]
FLAGS
--json Output tokens in JSON format
OVERRIDE FLAGS
-p, --project-id=<id> Project ID to list tokens for (overrides CLI configuration)
DESCRIPTION
List API tokens for the current project
EXAMPLES
List tokens for the current project
$ sanity tokens list
List tokens in JSON format
$ sanity tokens list --json
List tokens for a specific project
$ sanity tokens list --project-id abc123