Tokens CLI command reference

Create, inspect and manage tokens

npx sanity tokens --help

Commands

create

USAGE
  $ sanity tokens create [LABEL] [-p <id>] [--yes] [--expires-at 2027-01-01] [--grant context=editor] [--json] [--organization <id>] [--role viewer]

ARGUMENTS
  [LABEL]  Label for the new token

FLAGS
  -y, --yes                    Skip prompts and use defaults (unattended mode)
      --expires-at=2027-01-01  Date or timestamp the token expires (ISO 8601; tokens never expire by default)
      --grant=context=editor   Access to grant, as <permission>[=<role>] or project:<projectId>=<role>[,<role>]. Permissions: context, blueprints, media-library, canvas, sdk-apps, access, deploy-studios. Repeatable
      --json                   Output as JSON
      --role=viewer            Role to assign on the project (defaults to viewer in unattended mode)

OVERRIDE FLAGS
  -p, --project-id=<id>    Project ID to create token in (overrides CLI configuration)
      --organization=<id>  Organization to create an organization token in (overrides CLI configuration)

DESCRIPTION
  Create a new API token with access to an organization and its projects

EXAMPLES
  Create a token, choosing its access interactively

    $ sanity tokens create "My API Token"

  Create an organization token with Context, Blueprints and project access

    $ sanity tokens create "CI Token" --grant context=developer --grant blueprints --grant project:abc123=editor

  Create a project token with editor role

    $ sanity tokens create "My Token" --project-id abc123 --role=editor

  Create a project token in unattended mode

    $ sanity tokens create "CI Token" --role=editor --yes

  Create a token that expires on a given date

    $ sanity tokens create "Build Token" --expires-at 2027-01-01

  Output token information as JSON

    $ sanity tokens create "API Token" --json

delete

USAGE
  $ sanity tokens delete [TOKENID] [-p <id>] [--yes] [--organization <id>]

ARGUMENTS
  [TOKENID]  Token ID to delete (will prompt if not provided)

FLAGS
  -y, --yes                Skip confirmation prompt (unattended mode)
      --organization=<id>  Delete a token managed by this organization

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to delete token from (overrides CLI configuration)

DESCRIPTION
  Delete an API token from a project or organization

EXAMPLES
  Interactively select and delete an organization token

    $ sanity tokens delete --organization org123

  Delete an organization token without confirmation

    $ sanity tokens delete silJ2lFmK6dONB --organization org123 --yes

  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 abc123

list

USAGE
  $ sanity tokens list [-p <id>] [--json] [--organization <id>]

FLAGS
      --json               Output tokens in JSON format
      --organization=<id>  List tokens managed by this organization

OVERRIDE FLAGS
  -p, --project-id=<id>  Project ID to list tokens for (overrides CLI configuration)

DESCRIPTION
  List API tokens for a project or organization

EXAMPLES
  List tokens managed by an organization

    $ sanity tokens list --organization org123

  List tokens for the 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

rotate

USAGE
  $ sanity tokens rotate [-t <token>] [--json]

FLAGS
  -t, --token=<token>  Token to rotate (prefer standard input to keep it out of shell history)
      --json           Output as JSON

DESCRIPTION
  Rotate an API token, replacing its secret with a new one

EXAMPLES
  Rotate the token piped on standard input

    $ echo "$SANITY_TOKEN" | sanity tokens rotate

  Rotate a token read from a file

    $ sanity tokens rotate < token.txt

  Output the rotated token as JSON

    $ echo "$SANITY_TOKEN" | sanity tokens rotate --json

Was this page helpful?

sanity.ioAll Systems Operational© Sanity 2026
Change site theme