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]
ARGUMENTS
[LABEL] Label for the new token
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to add token to (overrides CLI configuration)
--json Output as JSON
--role=<ROLE> Role to assign to the token
-y, --yes Skip prompts and use defaults (unattended mode)
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]
ARGUMENTS
[TOKENID] Token ID to delete (will prompt if not provided)
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to delete token from (overrides CLI configuration)
--yes Skip confirmation prompt (unattended mode)
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
FLAGS
-p, --project-id=<PROJECT-ID> Project ID to list tokens for (overrides CLI configuration)
--json Output tokens in JSON format
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