User missing sanity.project/update grant when deploying Studio

3 replies
Last updated: Aug 17, 2023
πŸ‘‹ Hello, team! I am not able to deploy sanity studio for my project.
I have tried executing
yarn sanity deploy
and after answering a couple of questions it fails saying
User is missing required grant sanity.project/update to perform this operation
I have tried with admin and deploy tokens, both in
.env
file and actual environment variable.
Any ideas?
AI Update

The error User is missing required grant sanity.project/update to perform this operation indicates an authentication or permissions issue with your deployment. Here's how to resolve it:

The Core Issue

This error means the credentials you're currently using don't have the necessary permissions to deploy the Studio. Even though you've tried using admin and deploy tokens in your .env file, something isn't authenticating correctly.

Solution Steps

1. Clear your current authentication and log in interactively:

npx sanity logout
npx sanity login

The sanity login command will open a browser window for you to authenticate with your Sanity account. This ensures you're using proper credentials with the right permissions.

2. Verify your account has the right project role:

According to the Sanity access control documentation, you need Administrator role to deploy. Check your role in your project settings on sanity.io. Contributors, Viewers, or Editors won't have deployment permissions.

3. Try deploying again:

yarn sanity deploy

About Using Tokens

The sanity deploy documentation mentions that tokens can be used for deployment via the SANITY_AUTH_TOKEN environment variable, particularly in CI/CD environments. However, if you're getting this error with tokens, the token itself likely doesn't have the correct permissions, or there's a conflict between your environment variables and CLI authentication.

Additional Troubleshooting

If logging in interactively doesn't resolve the issue:

  • Double-check your sanity.config.js: Ensure the projectId matches the project you have Administrator access to
  • Remove conflicting environment variables: Temporarily unset SANITY_AUTH_TOKEN from both your .env file and actual environment variables while using interactive login
  • Verify your CLI version: Update to the latest version with npm install -g sanity@latest
  • Check you're in the right directory: Make sure you're running the command from your Studio's root directory

Once you successfully deploy with interactive login, you can then set up automated deployments with tokens in CI/CD pipelines if needed.

Show original thread
3 replies
Could you take a look at the solution in this thread to see if it works for you? Thanks.
Will do. Thanks
Found the problem. It seems for the very first deployment I need to be logged using
sanity login
. After that the deploy token works properly.

Sanity – Build the way you think, not the way your CMS thinks

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.

Was this answer helpful?