How to dynamically create a subdomain?

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

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

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

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

So we can dynamically create or update subdomains with this api call, in custom_domain field?
I am thinking of making a resume builder site and allow users to choose subdomains to edit their pages

Sure, that should work.

Please be sure that you have a Pro or higher level account with us if you are charging your users for your service; our terms of service require people who “sell” our service to their customers to be paying users with a Pro or higher account.