CLI reference

Login CLI command reference

Authenticates against the Sanity.io API or a third-party identity provider via SAML SSO (Business / Enterprise plan feature).

The sanity login process requires a browser. To run a command that requires authentication but where a browser is not available, such as on a server, you can login locally, run sanity debug --secrets to get a personal auth token, and then precede the command requiring authentication with SANITY_AUTH_TOKEN=<token>.

SANITY_AUTH_TOKEN=ab97ae7...0f9ff sanity init -y \
  --create-project "Movies Unlimited" \
  --dataset moviedb \
  --visibility private \
  --template moviedb \
  --output-path /path/to/folder

Login with SAML SSO

SAML SSO Prerequisites

Users configured with SAML SSO can use the --sso flag when logging in to pass their slug and log into a project using their third-party identity provider. The slug is set via the Sanity Management Console and is configured under the Settings tab for the Organization.

usage: sanity login --sso <slug>

   Authenticates against a third-party identity provider

To sign in as a different user, run sanity login again. The CLI invalidates the previous session and writes the new token in one step. See CLI authentication for the full auth surface, including SSO, robot tokens, and token storage.

Was this page helpful?