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?

Nov 13, 2020, 8:10 AM

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/>&lt;projectId&gt;' \
-H 'Authorization: Bearer &lt;token&gt;' \
-H 'Content-Type: application/json' \
-d '{
	"studioHost": "&lt;hostname&gt;"
}'
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
)?

Nov 13, 2020, 10:27 AM

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.

Nov 13, 2020, 10:51 AM

Sorry for asking, that curl --request one, should i use that in the terminal? with my auth token?

Nov 13, 2020, 10:53 AM

totally new to this

Nov 13, 2020, 10:53 AM

That's correct! 🙂

Nov 13, 2020, 10:54 AM

Thanks a lot, now it works! 🙂
Is it possbile to make a .env to protect the id in sanity project aswell?

Nov 13, 2020, 11:06 AM

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
🙂

Nov 13, 2020, 11:13 AM

Sanity.io: Get the most out of your content

Sanity.io is a platform to build websites and applications. It comes with great APIs that let you treat content like data. Give your team exactly what they need to edit and publish their content with the customizable Sanity Studio. Get real-time collaboration out of the box. Sanity.io comes with a hosted datastore for JSON documents, query languages like GROQ and GraphQL, CDNs, on-demand asset transformations, presentation agnostic rich text, plugins, and much more.

Don't compromise on developer experience. Join thousands of developers and trusted companies and power your content with Sanity.io. Free to get started, pay-as-you-go on all plans.