> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# CopySiteAsTemplate

# Package: studioWorkspace

# Namespace: Templates

# Method link: https://dev.wix.com/docs/api-reference/account-level/studio-workspace/template-v1/copy-site-as-template.md

## Permission Scopes:
SCOPE.STUDIO.MANAGE-CUSTOM-TEMPLATES: SCOPE.STUDIO.MANAGE-CUSTOM-TEMPLATES

## Introduction

Creates a template by duplicating an existing site.

Duplicates the site specified in `siteMetaSiteIdToCopy`, then turns the duplicate into a template. The original site is left unchanged.

---

## REST API

### Schema

```
 Method: copySiteAsTemplate
 Description: Creates a template by duplicating an existing site.  Duplicates the site specified in `siteMetaSiteIdToCopy`, then turns the duplicate into a template. The original site is left unchanged.
 URL: https://www.wixapis.com/wixstudio/templates/v1/templates/copy-site
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  templateName, siteMetaSiteIdToCopy
 Method parameters: 
   param name: siteMetaSiteIdToCopy | type: siteMetaSiteIdToCopy | description: GUID of the site to duplicate and create the template from. | required: true | validation: format GUID
   param name: templateName | type: templateName | description: Name of the template to create. | required: true | validation: minLength 4, maxLength 20
   param name: templateType | type: TemplateType    
      - enum:
           UNKNOWN - Unknown template type.
           STUDIO - Standard template created from a site.
           PUBLIC - Published template that other Wix accounts can clone.
 Return type: CopySiteAsTemplateResponse
  - name: template | type: Template | description: Created template.  
     - name: id | type: string | description: Template GUID.  | validation: format GUID
     - name: name | type: string | description: Template name.  | validation: minLength 4, maxLength 20
     - name: sites | type: Sites | description: Sites created from this template within the current account.  
        - name: metaSiteIds | type: array<string> | description: IDs of the sites created from this template within the current account.  | validation: maxItems 1000, format GUID
        - name: count | type: integer | description: Number of sites created from this template within the current account.  | validation: format int32
     - name: createdBy | type: string | description: GUID of the user who created the template.  | validation: format GUID
     - name: lastEditedBy | type: string | description: GUID of the user who last edited the template's site.  | validation: format GUID
     - name: lastEditedDate | type: string | description: Date and time the template's site was last edited.  | validation: format date-time
     - name: revision | type: string | description: Revision number, which increments by 1 each time the template is updated. To prevent conflicting changes, the current revision must be passed when updating the template. Ignored when creating a template.  | validation: format int64
     - name: createdDate | type: string | description: Date and time the template was created.  | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the template was updated.  | validation: format date-time
     - name: templateType | type: TemplateType | description: Type of the template.  
         - enum:
         -     UNKNOWN: Unknown template type.
         -     STUDIO: Standard template created from a site.
         -     PUBLIC: Published template that other Wix accounts can clone.
     - name: hidden | type: boolean | description: Whether the template is hidden from template galleries and pickers. A hidden template still exists and can be used to create sites, but doesn't appear in template lists. Default: `false`.  
     - name: platform | type: Platform | description: Platform the template's site was built on. Derived automatically from the site.  
         - enum:
         -     STUDIO: Site built with Wix Studio.
         -     WIX: Site built with the Wix Editor.


```

### Examples

### Copy Site As Template
Duplicates an existing site and turns the duplicate into a new template. The original site is left unchanged.

```curl
curl -X POST \
  'https://www.wixapis.com/wixstudio/templates/v1/templates/copy-site' \
  -H 'Authorization: <AUTH>' \
  -H 'Content-Type: application/json' \
  --data-binary '{
    "templateName": "Portfolio Starter",
    "siteMetaSiteIdToCopy": "b2c4e8f1-3a5d-47b9-8e2c-1f9a6d3b7c45",
    "templateType": "STUDIO"
  }'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.templates.wixTemplatesBackend.copySiteAsTemplate(templateName, options)
 Description: Creates a template by duplicating an existing site.  Duplicates the site specified in `siteMetaSiteIdToCopy`, then turns the duplicate into a template. The original site is left unchanged.
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  templateName, options.siteMetaSiteIdToCopy, options
 Method parameters: 
   param name: options | type: CopySiteAsTemplateOptions  none | required: true 
        - name: siteMetaSiteIdToCopy | type: string | description: GUID of the site to duplicate and create the template from. | required: true | validation: format GUID
        - name: templateType | type: TemplateType | description: Type of the template to create.  
             - enum:
             -     UNKNOWN: Unknown template type.
             -     STUDIO: Standard template created from a site.
             -     PUBLIC: Published template that other Wix accounts can clone.
   param name: templateName | type: string | description: Name of the template to create. | required: true | validation: minLength 4, maxLength 20
 Return type: PROMISE<CopySiteAsTemplateResponse>
  - name: template | type: Template | description: Created template.  
     - name: _id | type: string | description: Template GUID.  | validation: format GUID
     - name: name | type: string | description: Template name.  | validation: minLength 4, maxLength 20
     - name: sites | type: Sites | description: Sites created from this template within the current account.  
        - name: metaSiteIds | type: array<string> | description: IDs of the sites created from this template within the current account.  | validation: maxItems 1000, format GUID
        - name: count | type: integer | description: Number of sites created from this template within the current account.  | validation: format int32
     - name: createdBy | type: string | description: GUID of the user who created the template.  | validation: format GUID
     - name: lastEditedBy | type: string | description: GUID of the user who last edited the template's site.  | validation: format GUID
     - name: lastEditedDate | type: Date | description: Date and time the template's site was last edited.  
     - name: revision | type: string | description: Revision number, which increments by 1 each time the template is updated. To prevent conflicting changes, the current revision must be passed when updating the template. Ignored when creating a template.  | validation: format int64
     - name: _createdDate | type: Date | description: Date and time the template was created.  
     - name: _updatedDate | type: Date | description: Date and time the template was updated.  
     - name: templateType | type: TemplateType | description: Type of the template.  
         - enum:
         -     UNKNOWN: Unknown template type.
         -     STUDIO: Standard template created from a site.
         -     PUBLIC: Published template that other Wix accounts can clone.
     - name: hidden | type: boolean | description: Whether the template is hidden from template galleries and pickers. A hidden template still exists and can be used to create sites, but doesn't appear in template lists. Default: `false`.  
     - name: platform | type: Platform | description: Platform the template's site was built on. Derived automatically from the site.  
         - enum:
         -     STUDIO: Site built with Wix Studio.
         -     WIX: Site built with the Wix Editor.


```

### Examples

### Copy site as template //
Duplicates an existing site and turns the duplicate into a new template

```javascript
import { wixWixstudioTemplatesV1Template } from "@wix/dev";

const templateName = "Portfolio Starter";

const options = {
  siteMetaSiteIdToCopy: "b2c4e8f1-3a5d-47b9-8e2c-1f9a6d3b7c45",
  templateType: "STUDIO",
};

async function copySiteAsTemplate() {
  const response = await wixWixstudioTemplatesV1Template.copySiteAsTemplate(
    templateName,
    options,
  );
}

/* Promise resolves to:
 * {
 *   "template": {
 *     "_id": "d7a341c4-196b-46e7-813c-2b0fb1847ec6",
 *     "name": "Portfolio Starter",
 *     "sites": { "metaSiteIds": [], "count": 0 },
 *     "revision": "1",
 *     "_createdDate": "2026-06-01T09:15:00.000Z",
 *     "_updatedDate": "2026-06-01T09:15:00.000Z",
 *     "templateType": "STUDIO",
 *     "hidden": false,
 *     "platform": "STUDIO"
 *   }
 * }
 */

```

### copySiteAsTemplate (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { wixTemplatesBackend } from '@wix/templates';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { wixTemplatesBackend },
  // Include the auth strategy and host as relevant
});


async function copySiteAsTemplate(templateName,options) {
  const response = await myWixClient.wixTemplatesBackend.copySiteAsTemplate(templateName,options);
};
```

---