
Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag storeYou're getting this error because the Sanity CLI needs authentication when running in a CI/CD environment like CircleCI. The sanity graphql deploy command requires authentication, but the interactive sanity login doesn't work in automated environments.
The solution is to use the SANITY_AUTH_TOKEN environment variable. Here's how to set it up:
Generate a token in your Sanity project management dashboard:
Add the token to CircleCI:
SANITY_AUTH_TOKENThe CLI will automatically use it - no code changes needed! When the SANITY_AUTH_TOKEN environment variable is set, the Sanity CLI will use it for authentication instead of requiring an interactive login.
Your CircleCI config should work as-is:
#!/bin/bash -eo pipefail
sanity graphql deploy --dataset=staging --tag default --playgroundAccording to the CLI Configuration documentation:
When you need to run the CLI unattended, like in a CI/CD environment, set the
SANITY_AUTH_TOKENenvironment variable to a token.
Important: Make sure the token you generate has sufficient permissions for deploying GraphQL schemas. You may need a token with "Deploy Studio" or similar permissions depending on your project setup.
Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.
Content operations
Content backend


The only platform powering content operations
By Industry


Tecovas strengthens their customer connections
Build and Share

Grab your gear: The official Sanity swag store
Read Grab your gear: The official Sanity swag store