How to dynamically create a subdomain?

answered
#1

I would like to be able to create subdomains that point to different repos in github. I know I can do branch deploys, but that is not what I need.
The scenario would be i make an API call and authorize netlify to use my github account and give it permissions to a repo. Then later I authorize it to use a different repo, but that has to be a subdomain of the same root domain.
I have been able to do this manually, but I’d like to use the API. I’m sure there’s a way, but I can’t seem to find it

#2

Hi @alopez, where are these subdomains pointing? Are you changing the custom domain on the site? or are you adding them as domain aliases? or if it’s something else, let us know. Thanks. Also note that either way you can use our API to change the domains on your site just as we do on app.netlify.com

#3

I have domain.com as my home page, but I want to be able to create sub.domain . com and sub1.domain . com etc with the API. I’m positive that it can be done, because I have done it in the admin console. I’m wondering if when I create the new site setting the custom_domain to the subdomain would work

#4

Yup, you can create sites and add custom domains using our API. You can get started using our API by reading through this topic.