How to set studio hostname via API?

7 replies
Last updated: Nov 13, 2020
I saw that I have a new problem but with sanity now, when i doing sanity deploy, i getting to choose my studio hostname, and when i choose one and click enter, nothing else happens, it just stops there, so it doesnt deploy it, anyone know why?
AI Update

I understand how frustrating that is! When sanity deploy stops after you choose a hostname and press Enter, this is usually related to a few common issues. Let me walk you through the most likely causes and solutions:

Authentication Issues

The most common reason for the deployment hanging after hostname selection is authentication problems. The CLI might be failing silently because it can't verify your credentials. Try running:

sanity login

This will refresh your authentication token. Then try sanity deploy again. If you're deploying from a CI/CD environment, make sure you have a valid SANITY_AUTH_TOKEN environment variable set, as mentioned in the Azure DevOps deployment guide.

Outdated CLI Version

An outdated CLI version can cause unexpected behavior during deployment. Update to the latest version:

npm install -g @sanity/cli@latest
# or if using the project locally
npm install @sanity/cli@latest

After updating, try deploying again.

Terminal/Input Handling Issues

Sometimes terminal input buffering or encoding issues can cause the Enter key to not register properly:

  • Try using a different terminal (if on Windows, try PowerShell vs CMD vs Git Bash)
  • Try pressing Enter multiple times
  • Check if your terminal is actually waiting for input (sometimes there are additional prompts that aren't visible)

Network or Firewall Problems

The deployment might be hanging on network requests after you press Enter. Check if:

  • Your firewall or corporate proxy is blocking connections to Sanity's deployment servers
  • You have a stable internet connection
  • Your DNS is resolving correctly

Try running the deploy command with verbose output to see if there are network errors:

sanity deploy --verbose

Build Issues

Sometimes the Studio build itself fails silently. Before deploying, try building locally first:

sanity build

This will show you any build errors that might be causing the deployment to fail.

Check Your Project Configuration

Make sure your sanity.config.ts (or .js) file is properly configured with your project ID and dataset. Missing or incorrect configuration can cause deployment issues.

Alternative Troubleshooting Steps

If none of the above work:

  1. Check the Sanity management console: Go to sanity.io/manage and verify your project exists and you have proper permissions
  2. Try deploying to a different hostname: Sometimes specific hostnames might have conflicts
  3. Clear your CLI cache: Delete the .sanity folder in your project and try again

Get Help

If you're still stuck, the Sanity Slack community is very active and responsive to deployment issues. You can also check GitHub discussions for similar issues. When asking for help, include:

  • Your CLI version (sanity --version)
  • Your Node.js version (node --version)
  • Any error messages from sanity deploy --verbose
  • Your operating system

The sanity deploy command builds and deploys your Studio to Sanity's hosted environment at [your-hostname].sanity.studio, and as explained in the deployment documentation, it also deploys your schema for use with other Sanity platform features. When it works correctly, you should see build progress and then deployment confirmation.

Show original thread
7 replies
Hi Markus, if you’re comfortable using the HTTP API, you could try setting your studio hostname that way:
curl --request PATCH '<https://api.sanity.io/v1/projects/><projectId>' \
-H 'Authorization: Bearer <token>' \
-H 'Content-Type: application/json' \
-d '{
	"studioHost": "<hostname>"
}'
To get the token, you can run 
sanity debug --secrets
 in the CLI and use the auth token listed in the output.
As for why it's not working with the deploy command, I'm not sure but it's something we'll investigate. Are you on the latest version (
sanity versions
)?
Hi thanks for answer, I will try it out. Yeah I guess so, I did sanity init and create the blog schema one so i guess so.
Sorry for asking, that curl --request one, should i use that in the terminal? with my auth token?
totally new to this
That's correct! 🙂
Thanks a lot, now it works! 🙂
Is it possbile to make a .env to protect the id in sanity project aswell?
Glad to hear!
Check Bjørge's response in your previous thread regarding the project ID: it's not considered a secret, but you can load it from an env variable, yep
🙂

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?