CLI reference
Tokens
Create, inspect and manage tokens
usage: npx sanity tokens [--default] [-v|--version] [-d|--debug] [-h|--help] <command> [<args>] Commands: add Create a new API token for this project delete Delete an API token from this project list List all API tokens for this project See 'npx sanity help tokens <command>' for specific information on a subcommand.
Commands
Add
Usage sanity tokens add "My API Token" sanity tokens add "My API Token" --role=editor sanity tokens add "My API Token" --role=viewer Options --role <role> Role to assign to the token. Default: editor
Delete
Usage sanity tokens delete sanity tokens delete silJ2lFmK6dONB sanity tokens delete "My API Token" Options --force Skip confirmation prompt
List
Usage sanity tokens list sanity tokens list --json Options --json JSON output format
Examples
# Interactive token creation (prompts for role) sanity tokens add "My Token" # Create token with specific role (no prompts) sanity tokens add "CI Token" --role=editor # Unattended mode with default role sanity tokens add "Deploy Token" --yes # JSON output for programmatic usage sanity tokens add "API Token" --json # List all tokens sanity tokens list # List as JSON sanity tokens list --json # Delete token (interactive selection) sanity tokens delete # Delete specific token by ID (unattended) sanity tokens delete silJ2lFmK6dONB --yes
Was this page helpful?