Sanity Deploy "You do not have access to the project" Error Despite Correct Login

46 replies
Last updated: Apr 26, 2023
I am getting "You do not have access to the project with ID '...'. You may need to login again with sanity login." when I try and
sanity deploy
from my studio directory in Terminal. Reading the docs for this error is not helpful , I am logged into that same account, it's my only project, and the project ID is exactly the same. What do I do?
AI Update

This is a frustrating authentication issue that comes up occasionally! The "You do not have access to the project" error during sanity deploy is almost always caused by stale or corrupted authentication tokens in the Sanity CLI, even when you appear to be logged in.

Here's what to try:

1. Force a fresh login

Run these commands in order:

sanity logout
sanity login

This clears your existing auth token and creates a new one. After logging back in, try sanity deploy again.

2. Check your auth token location

The Sanity CLI stores authentication tokens in a config file. On macOS/Linux, this is typically at ~/.config/sanity/config.json. Sometimes this file gets corrupted or contains tokens from old sessions.

You can manually delete this file and log in again:

rm ~/.config/sanity/config.json
sanity login

On Windows, the config is usually stored in %USERPROFILE%\.config\sanity\config.json.

3. Verify your project ID

Double-check that the projectId in your sanity.config.ts (or sanity.json for older projects) exactly matches your actual project ID in manage.sanity.io. Even a single character difference will cause this error.

4. Check project permissions

Go to manage.sanity.io, select your project, and verify under Settings → Members that your account actually has admin or deploy permissions. If you were recently added to a project by someone else, you might not have the right role.

5. Try with an explicit auth token

As mentioned in the sanity deploy documentation, you can bypass the stored credentials by using an environment variable:

SANITY_AUTH_TOKEN=your-token-here sanity deploy

You can generate a token at manage.sanity.io under your project's Settings → API → Tokens.

Why this happens:

The CLI authentication can get out of sync if you've logged in from multiple machines, changed your Sanity password, or if there were network issues during a previous login. The logout/login cycle forces the CLI to request a fresh token from Sanity's servers.

In 99% of cases, the sanity logoutsanity login sequence fixes this immediately. If it still doesn't work after that, there's likely a permissions issue with your Sanity account on that specific project.

Show original thread
46 replies
You tried different browsers?
Wait, what? Tried different browsers to deploy from Terminal?
Oh i read it wrong, ive seen login issues before so that was my first thought
I tried logging out, and back in.
Project ID is the same in my dashboard. I am the only user of this account, so I am the admin.
Thanks anyway
user U
You’re likely using a different provider to log into the CLI than you are to Manage.
Provider...
I do only have one Sanity account
The method you’re using to log in
You’ve probably created two accounts by accident
Uh, how does one delete one account but not the other?
Log in to Manage using the method for the account you’d like to delete, then click delete account under settings.
So to be clear, I can have two accounts with one email address?
I am going to delete the only account I know I have.
Oh which means I have to delete this project
If the project shows up under the account in manage, don’t delete that account.
Too late, account deleted.
Well that confirmed I had two accounts!
Going back to sanity.io shows another email I did not know I signed up with.
Can I connect an existing local Sanity project to a new Sanity project online?
Actually, I am pretty sure I somehow had two accounts for the same email address.
Frank, you are reminding me of something my father taught me quite small -- and had to unteach me as it was an instant favorite to say everywhere, but maybe I bring it back this once :)
...Confucius said, 'Patience is a virtue' ..., and imagine a two year old with this!
Easier said than done when on deadline using new tech to replace your 15 years of WordPress knowledge. 😅
(my father grew up in China)
and yes, you are on the rapid road :)
I learn by failing, hard sometimes, but fast
Like now, no idea if updating this project ID will work
... and that worked!
BTW, if this happens again, you can check the provider you need to use in Manage. Then run
sanity logout && sanity login
and use the method pictured.
I used email, and it was the same email address
user M
Like I said, it can be the same email address. The provider matters as well. If you created the account using an email and password, then used google to log into the CLI those would be two different accounts.
I email/password as a default in life. I never rely on third party providers. That's why when you said provider, I didn't really understand what you meant.
Look at Twitter. 🙄
Lol don’t make me
It's a good reason to never trust a third party provider. ☺️
Ah, but I am also very lazy…
But using something like 1 pass to handle it does make about the same level of ease
I am a devout 1Password user
I am now after being burned by last pass…
cool tip,
user M
, and you are the beneficiary of Google BigQuery beneficence,
user P
Oh this is interesting. I lost everything.
Thankfully I wasn't far, but when I start my local Studio all my content is missing.
That's, shocking.
Did you replace the project ID or create a different dataset? If so, that would explain it.
Yes, I replaced the project ID because I didn’t have a project showing up.

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?