Sanity logosanity.ioAll Systems Operational© Sanity 2026
Change Site Theme
Sanity logo

Documentation

    • Overview
    • Platform introduction
    • Next.js quickstart
    • Nuxt.js quickstart
    • Astro quickstart
    • React Router quickstart
    • Studio quickstart
    • Build with AI
    • Content Lake
    • Functions
    • APIs and SDKs
    • Agent Actions
    • Visual Editing
    • Blueprints
    • Platform management
    • Dashboard
    • Studio
    • Canvas
    • Media Library
    • App SDK
    • Content Agent
    • HTTP API
    • CLI
    • Libraries
    • Specifications
    • Changelog
    • User guides
    • Developer guides
    • Courses and certifications
    • Join the community
    • Templates
CLI reference
Overview

  • Configuration
  • Commands

    Backup CLI command reference
    Blueprints
    Build
    Codemod
    CORS
    Dataset
    Debug
    Deploy
    Dev
    Docs
    Documents
    Exec
    Functions
    GraphQL
    Help
    Hook
    Init
    Install
    Login
    Logout
    Manage
    Manifest
    Media
    Migration
    Preview
    Projects
    Schema
    Start
    Telemetry
    TypeGen
    Undeploy
    Users
    Versions
    Tokens

On this page

Previous

Versions

Was this page helpful?

On this page

  • Commands
  • Add
  • Delete
  • List
  • Examples
CLI referenceLast updated July 4, 2025

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
  • Article
  • Changelog
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.
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
Usage
  sanity tokens delete
  sanity tokens delete silJ2lFmK6dONB
  sanity tokens delete "My API Token"
Options
  --force Skip confirmation prompt
Usage
  sanity tokens list
  sanity tokens list --json
Options
  --json JSON output format
# 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