# Is auto clone and deploy to a new sub domain possible?

**URL:** <https://answers.netlify.com/t/is-auto-clone-and-deploy-to-a-new-sub-domain-possible/32663>\
**Category:** Support\
**Tags:** deployment\
**Created:** [February 17, 2021, 6:35pm UTC](https://answers.netlify.com/t/is-auto-clone-and-deploy-to-a-new-sub-domain-possible/32663 "2021-02-17T18:35:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![1111](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/1111/32/23695_2.png) [@1111](https://answers.netlify.com/u/1111)\
**Post date:** [February 17, 2021, 6:35pm UTC](https://answers.netlify.com/t/is-auto-clone-and-deploy-to-a-new-sub-domain-possible/32663/1 "2021-02-17T18:35:56Z")

</div>

I host a react app on a custom domain at Netlify via github. I’d like to ask if it’s possible to automatically clone and deploy to a new sub domain by actioning a script within the app itself?

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [February 19, 2021, 9:04am UTC](https://answers.netlify.com/t/is-auto-clone-and-deploy-to-a-new-sub-domain-possible/32663/2 "2021-02-19T09:04:59Z")

</div>

Hi, @1111. Yes, it is hypothetically possible to do this. However, if and how to actually do this depend on numerous details about how you plan to implement this. For example, when you say:

> [@1111](#):
>
> actioning a script within the app itself

what exactly does “actioning” mean? In other words, where do you want that script to be run?

Will you run the script on your local system? Do you want to use GitHub actions? Do you want to run code in the end user’s browser to trigger the deploy? Will the script be run as a [Function](https://docs.netlify.com/functions/overview/)?

All of those are possible. Not all of them are good ideas (for example, you probably don’t want people visiting your website triggering builds) but they can all be done in some way. However, each of them would likely be done in different ways so knowing how you intend to run the script will be an important part of answering.

---

<div class="post-metadata">

**Author:** ![1111](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/1111/32/23695_2.png) [@1111](https://answers.netlify.com/u/1111)\
**Post date:** [February 21, 2021, 3:13pm UTC](https://answers.netlify.com/t/is-auto-clone-and-deploy-to-a-new-sub-domain-possible/32663/3 "2021-02-21T15:13:17Z")

</div>

Luke thanks. At least it’s theoretically possible. Actually I do want a user to trigger a new build I think. I’m looking for the simplest way of triggering a new build of a react template stored in github, under a new sub domain hosted on netlify. If you could give me some pointers that would be excellent

---

<div class="post-metadata">

**Author:** ![luke](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/luke/32/39_2.png) [@luke](https://answers.netlify.com/u/luke)\
**Post date:** [March 1, 2021, 8:20am UTC](https://answers.netlify.com/t/is-auto-clone-and-deploy-to-a-new-sub-domain-possible/32663/4 "2021-03-01T08:20:22Z")

</div>

Hi, @1111. As far as pointers, you can see our API documentation here:

> **[Netlify](https://open-api.netlify.com/)**
>
> Deploy modern static websites with Netlify. Get CDN, Continuous deployment, 1-click HTTPS, and all the services you need. Get started for free.

There are also the two support guides below:

> [@\[Support Guide\] Understanding and using Netlify's API](https://answers.netlify.com/t/support-guide-understanding-and-using-netlifys-api/160):
>
> Last reviewed by Netlify Support staff: August 2023 Did you know that Netlify has an [extensive public API](https://open-api.netlify.com/)? Anything that you configure in our Admin UI at [https://app.netlify.com](https://app.netlify.com) is managed using this same API, and you’re welcome to use it to create and configure your site(s) and perform most other operations on your account. We have an article on [API Usage in our official documentation](https://docs.netlify.com/api/get-started/) which shows how to do some common tasks like deploying your site and configuring it in great detail. It also …

> [@\[Support Guide\] Linking a repository via API](https://answers.netlify.com/t/support-guide-linking-a-repository-via-api/121):
>
> Last reviewed by Netlify Support Staff: August 2023 It is easiest to link a repository in Netlify’s UI; doing it via API is challenging and should be a rare use case. Nonetheless, it is possible to create a Netlify site linked to a repository at any of our supported git providers programatically. Specifically, it is possible to use Netlify’s REST API for these situations. You’ll probably be interested in the general topics around “how do I use Netlify’s REST API?” (see [this support guide](https://answers.netlify.com/t/support-guide-understanding-and-using-netlifys-api/160), as w…

Do you want the user to create a new site under your existing team? If so, you could make Functions that have an API key from Netlify embedded in them and then have the site call those functions to create the new site

If you plan to take that route, then the following support guide about embedding API keys will be helpful:

> [@\[Support Guide\] How do I keep my API keys/tokens safe using Netlify Functions?](https://answers.netlify.com/t/support-guide-how-do-i-keep-my-api-keys-tokens-safe-using-netlify-functions/293):
>
> Last reviewed by Netlify Support on Oct 2023 With Jamstack sites, using API keys/tokens to make API calls to other services is a frequent pattern. In some cases, you may want to hard code the keys in your html, when invoking those API calls - which on a service like Netlify means these keys are now public. Anyone can open their browser dev tools and view them, and of course this can lead to someone abusing this access. In some cases, this is fine. For instance, some types of Firebase and Faun…

If there are other questions, please let us know.

---

<div class="post-metadata">

**Author:** ![1111](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/1111/32/23695_2.png) [@1111](https://answers.netlify.com/u/1111)\
**Post date:** [March 12, 2021, 8:04am UTC](https://answers.netlify.com/t/is-auto-clone-and-deploy-to-a-new-sub-domain-possible/32663/5 "2021-03-12T08:04:03Z")

</div>

Thank you Luke for your detailed reply. Much appreciated. Will get back and let you know how we are doing with this. Lots to discover with Netlify!
