# Duplicate site with API

**URL:** <https://answers.netlify.com/t/duplicate-site-with-api/53078>\
**Category:** Support\
**Tags:** git, netlify-api, deployment\
**Created:** [March 8, 2022, 3:23pm UTC](https://answers.netlify.com/t/duplicate-site-with-api/53078 "2022-03-08T15:23:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![brunocc](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/brunocc/32/35108_2.png) [@brunocc](https://answers.netlify.com/u/brunocc)\
**Post date:** [March 8, 2022, 3:23pm UTC](https://answers.netlify.com/t/duplicate-site-with-api/53078/1 "2022-03-08T15:23:14Z")

</div>

Hi,

Is there a way to duplicate a site using API ?  
In my usecase, I configure a site with my private gitlab repository and then need to duplicate the site with just a different environment variable and domain.  
I would like them to deploy automatically when I commit/push to that repository.

Best regards

---

<div class="post-metadata">

**Author:** ![hillary](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/hillary/32/21132_2.png) [@hillary](https://answers.netlify.com/u/hillary)\
**Post date:** [March 9, 2022, 4:07pm UTC](https://answers.netlify.com/t/duplicate-site-with-api/53078/2 "2022-03-09T16:07:34Z")

</div>

Hey there, @brunocc 👋

Thanks for reaching out! Have you seen this thread? I think it may help get you on the right track:

> [@Is it possible to copy a deployment from one site to another?](https://answers.netlify.com/t/is-it-possible-to-copy-a-deployment-from-one-site-to-another/31795/4):
>
> Hi, @feedm3. There are several possible approaches. Build and deploy at Netlify but don’t publish by [locking the current deploy.](https://docs.netlify.com/site-deploys/manage-deploys/#locked-deploys) After the checks are completed, only then publish the deploy. Do your build in a local or third-party build system and then [use the Netlify CLI tool to manually deploy](https://docs.netlify.com/cli/get-started/#manual-deploys) the build in the third-party. Build and deploy one one site and then download and manually upload that deploy to the production site. For option 3 above, you can download the deploy using the button s…

Let us know!

---

<div class="post-metadata">

**Author:** ![matus](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/matus/32/20689_2.png) [@matus](https://answers.netlify.com/u/matus)\
**Post date:** [September 27, 2022, 9:27am UTC](https://answers.netlify.com/t/duplicate-site-with-api/53078/3 "2022-09-27T09:27:05Z")

</div>

I don’t think this answers the question.  
Is there a simple way to duplicate/copy over all the site configuration to the new site?

---

<div class="post-metadata">

**Author:** ![fool](https://sea1.discourse-cdn.com/netlify/user_avatar/answers.netlify.com/fool/32/37_2.png) [@fool](https://answers.netlify.com/u/fool)\
**Post date:** [September 29, 2022, 11:56pm UTC](https://answers.netlify.com/t/duplicate-site-with-api/53078/5 "2022-09-29T23:56:59Z")

</div>

Like many things, the answer is “it depends”.

At a high level, no. There is no “create an exact copy of any site” API call. And in fact some settings are probably not “Create”-able, but must be activated with one call and then configured with another. You will spend substantial time trying to reverse engineer exactly how to configure domain aliases and other site settings such as large media, permissions, notifications, etc. Creating a generic site is easy ([Netlify API documentation](https://open-api.netlify.com/#operation/createSite)); creating a site with many specific settings is hard, nonintuitive (some settings can be passed to the siteUpdate call, others have to be passed to the updateSite or createSiteSnippet calls), and our docs do not attempt to address that use case.

But, as far as how your site builds and _some_ settings on it - things like asset optimization, environment variables, redirects, etc - you can use config as code: `netlify.toml`! This file lets you control how and what to build, what variables to set, what asset optimizations, redirects, and headers a site needs. All in one file, that is intended to be used this way. Here’s the docs on it:

> **[File-based configuration](https://docs.netlify.com/configure-builds/file-based-configuration/)**
>
> Use a netlify.toml configuration file to specify how the platform builds and deploys your project.

As far as “how you populate the toml with your values on gitlab and trigger the creation”, not sure about that. You might consider using the Deploy to Netlify button - which leverages the netlify.toml to set custom variables a public repo: [Create deploys | Netlify Docs](https://docs.netlify.com/site-deploys/create-deploys/#deploy-to-netlify-button)
